Anonymous enums specification

Lennart Blanco cokebuttle at gmail.com
Sat Jun 4 14:38:49 PDT 2011


On Fri, Jun 3, 2011 at 6:52 AM, Nick Sabalausky <a at a.a> wrote:

> "Lennart Blanco" <cokebuttle at gmail.com> wrote in message
> news:mailman.560.1307076213.14074.digitalmars-d at puremagic.com...
> > Hi
> >
> > The page for enums specification
> > http://www.digitalmars.com/d/2.0/enum.html defines<http://www.digitalmars.com/d/2.0/enum.htmldefines>enum body syntax as
> > follows:
> >
> > EnumBody:
> > ;
> > { EnumMembers }
> >
> > Should it not be
> >
> > EnumBody:
> > EnumMember ;
> > { EnumMembers }
> >
> > or perhaps
> >
> > EnumBody:
> > EnumMembers ;
> > { EnumMembers }
> >
> > Otherwise, I can't quite grasp how following enums definitions are legal:
> >
> > enum X = 4;
> >
> > enum
> >  mega = 1024 * 1024,
> >  pi = 3.14,
> >  euler = 2.72,
> >  greet = "Hello";
> >
> > (Both of the above enums are accepted by dmd v2.050).
> >
>
> It's a poorly-named hack to allow people to create manifest constants. Ie,
> they're like immutable values, but they don't actually take up any space in
> memory. In other words, it works just like C's "#define SOME_VALUE 5": the
> value just gets substituted into the code wherever the name is found.
>

Yes, I understand how anonymous enums works. My question was regarding the D
2.0 specification document. To me it looks like the syntax for anonymous
enums is missing in the specification. Only valid enum body definitions are
empty body or a list of enum members, delimited with '{' abd '}'.

/Lennart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110604/b9f2b0e4/attachment-0001.html>


More information about the Digitalmars-d mailing list