[dox] enum specs vs reality

Andre Artus andre.artus at gmail.com
Tue Aug 27 19:27:55 PDT 2013


On Tuesday, 27 August 2013 at 23:52:59 UTC, captaindet wrote:
> i admit that i am not very good at reading/understanding 
> language definition syntax. but yet i think the given enum 
> specs ( http://dlang.org/enum.html ) are not quite in order.
>
> they seem to imply that both
>
> enum ;
> enum WhatAmI ;

You are right. Given the rules marked with asterisks below your 
examples would be legal.

   EnumDeclaration:
   *       enum EnumTag EnumBody
   *       enum EnumBody
           enum EnumTag : EnumBaseType EnumBody
           enum : EnumBaseType EnumBody

   EnumBody:
   *       EmptyEnumBody
           EnumMembersBody

   EmptyEnumBody:
   *       ;



Going by the description on the linked page EmptyEnumBody should 
probably be something like this:

   EmptyEnumBody:
           EnumMember ;

Although going by examples [2] from Andrei's book ("The D 
Programming Language"), it seems the following is valid:

   EmptyEnumBody:
           EnumMembers ;


2. The example from p.69 [TDPL]. It seems to be missing a colon 
after "enum".
enum size_t g_maxDataSize = 100_000_000, g_maxMemory = 
1_000_000_000;

I hope someone can clear up what is and isn't a valid enum.


More information about the Digitalmars-d mailing list