D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10818 - Allow parameterized enum declaration
Summary: Allow parameterized enum declaration
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2013-08-13 08:49 UTC by Kenji Hara
Modified: 2024-12-13 18:10 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2013-08-13 08:49:37 UTC
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) {}
Comment 2 Walter Bright 2013-08-16 20:48:24 UTC
Are there any existing use cases that this would improve?
Comment 3 Kenji Hara 2013-08-16 22:57:47 UTC
(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.
Comment 4 dlangBugzillaToGithub 2024-12-13 18:10:17 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18646

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB