Tagged enums why reserved words are not permitted ?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 28 13:45:38 PDT 2014


On Tuesday, October 28, 2014 16:58:50 Gary Willoughby via Digitalmars-d-learn 
wrote:
> On Tuesday, 28 October 2014 at 00:51:17 UTC, Jonathan M Davis via
> Digitalmars-d-learn
>
> > The
> > thing that's been done in Phobos in this type of situation is
> > to put an
> > underscore on the end of the keyword, so you'd get
> >
> > enum CrudOps { read, write, delete_ }
> >
> > and while that may not be what you want, it's pretty much the
> > best that you
> > can do.
> >
> > - Jonathan M Davis
>
> This is also mentioned in the style guide too.
>
> http://dlang.org/dstyle.html

So, it is. I'd forgotten about that (even though I'm almost certainly the
one who put it there). But that's what we decided on when it came up in
std.traits a while back. It seemed like the only good way to use a keyword
as an identifier without breaking the naming conventions by doing something
like capitalizing it differently.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list