Tagged enums why reserved words are not permitted ?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 28 06:05:15 PDT 2014


On 10/27/14 8:31 PM, Domingo wrote:
> Hello !
>
> I'm not sure if I'm missing something here but for a tagged enum it
> doesn't seem to make sense to forbid reserved keywords like:
>
> enum CrudOps {read, write, delete}
>
> The dmd compiler are complaining:
> ------
> cte.d(4): Error: basic type expected, not delete
> cte.d(4): Error: no identifier for declarator int
> cte.d(4): Error: type only allowed if anonymous enum and no enum type
> cte.d(4): Error: if type, there must be an initializer
> cte.d(4): Error: found 'delete' when expecting ','
> ------
>
> It doesn't make sense to me because this kind of enum will not polute
> the global space and always need to beused with the tag: CrudOps.delete
>
> I'm missing something here ?
>
> Cheers !

http://en.wikipedia.org/wiki/Reserved_word

"Making keywords be reserved words makes lexing easier, as a string of 
characters will unambiguously be either a keyword or an identifier, 
without depending on context"

-Steve


More information about the Digitalmars-d-learn mailing list