[Issue 9065] Please consider adding these std.traits

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 27 06:26:00 PST 2012


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



--- Comment #32 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-11-27 06:25:56 PST ---
(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.

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..

-- 
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