Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parameterized enum declaration #18646

Open
dlangBugzillaToGithub opened this issue Aug 13, 2013 · 3 comments
Open

Allow parameterized enum declaration #18646

dlangBugzillaToGithub opened this issue Aug 13, 2013 · 3 comments

Comments

@dlangBugzillaToGithub
Copy link

Kenji Hara (@9rnsr) reported this on 2013-08-13T08:49:37Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=10818

CC List

Description

Aggregate declarations could have optional template parameters.

class C1 {}
class C2(T) {}

interface I1 {}
interface I2(T) {}

struct S1 {}
struct S2(T) {}

union U1 {}
union U2(T) {}

Similarly, parameterized enum declaration would increase language consistency.

enum E1 {}
enum E2(T) {}
enum E2(T) if (constraint) {}
enum E2(T) : T {}
enum E2(T) if (constraint) : T {}
enum E2(T) : T if (constraint) {}
@dlangBugzillaToGithub
Copy link
Author

k.hara.pg commented on 2013-08-13T09:17:14Z

https://github.com/D-Programming-Language/dmd/pull/2474

@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 2013-08-16T20:48:24Z

Are there any existing use cases that this would improve?

@dlangBugzillaToGithub
Copy link
Author

k.hara.pg commented on 2013-08-16T22:57:47Z

(In reply to comment #2)
> Are there any existing use cases that this would improve?

I don't have actual use case. I'm proposing this enhancement just for increasing language consistency.

---

Now I'm opening a compiler PR to extend DIP42 feature.
https://github.com/D-Programming-Language/dmd/pull/2467

This is necessary to support `enum bool x(T) = initializer` syntax, and looks to me it is very similar to N3651 in C++14.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3651.pdf

After #2467 is accepted, we would could make most of declarations parameterize - aggregates, functions, and variable declarations.

And, at that time enum declaration would be remained just one declaration which cannot be parameterized. That would be inconsistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant