[Issue 9065] Please consider adding these std.traits

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 27 06:43:39 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9065



--- Comment #33 from Manu <turkeyman at gmail.com> 2012-11-27 06:43:36 PST ---
(In reply to comment #32)
> (In reply to comment #29)
> > As a side point, what do you call X in: enum E { X = 10 } ?
> > 
> > Consider:
> >  enum E { X = 10 }
> >  enum Y = 10;
> > 
> > E.X and Y are both identical as far as I can tell.
> 
> Run typeid() on them.
> 
> > And every place it appears, it is clearly defined as being some subset of enum.
> 
> Well it wouldn't be the first time the docs lie. :)
> 
> "enum Y = 10;" is a special case which the compiler checks for and then parses
> this as a manifest constant, it does not parse it as an enum. "Y" is not an
> enum value of any sort, Y is a VarDeclaration with storage class STCmanifest.
> 
> Here:
> enum E { X = 10 }
> 
> X is an EnumMember.
> 
> Just to make this clear, these two are different:
> enum { X = 10 }
> enum Y = 10;
> 
> X is an enum value, whereas Y is a manifest constant and is not associated with
> enums at all in any way.

That's not really how the doc describes it: "If there is only one member of an
anonymous enum, the { } can be omitted:"

Either way, it's a perfectly reasonably way to visualise it as a user. As I
said before, I couldn't care less about internal compiler terminology, it looks
like an anonymous enum value, and the doc even says it's an anonymous enum
value. It must be so.

The doc is correct as far as I'm concerned, it makes perfect sense, the
language shouldn't be defined by implementation details of DMD.


> The issue here is that the "enum" keyword can be a lie. It can mean two things
> depending on the declaration.
> 
> It also seems that internally the idea of a manifest keyword was thought about,
> there's a bunch of commented out lines like so:
> //case TOKmanifest:   stc = STCmanifest;     goto Lstc;
> 
> I wonder who put that in and why it wasn't used..

I'll bet it was realised during implementation that it is actually syntactic
sugar for an anonymous enum, and the enum keyword was completely appropriate :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list