On Wednesday, September 01, 2010 12:36:04 Steven Schveighoffer wrote:
> AFAIK, enum meaning manifest constant was Andrei's request.  And I think
> if you have an idea to try and "fix" it, you might as well know now, it
> will never happen.  See this quote from Andrei in a bug report of mine
> (bug 1961):
> 
> "And enum... you'll have to yank that out from my dead cold hands.
> Extending
> enum instead of adding yet another way of defining symbolic constants is
> The
> Right Thing to do. I am sure people would have realized how ridiculous the
> whole "manifest" thing is if we first proposed it. We just can't define one
> more way for each kind of snow there is."
> 
> There was a point in D2 development with the 'manifest' keyword added to
> do exactly what enum now does (except for actual enumerations, for which
> enum was used).
> 
> FWIW, I am not a huge fan of enum being used for meaning manifest
> constants that are not enumerations, but as far as daily usage, it's not
> really bad.  It's somewhat of a petty problem, since enum is not
> functionally deficient.  It just looks weird, especially to those used to
> other languages.  I suppose you could think of it as an enumeration with
> one member :)
> 
> -Steve

It's the kind of thing that is distasteful from a language purity standpoint, 
but it really doesn't cause any problems in code as far as I can tell. Once you 
know that you use enum to declare a manifest constant, it's perfectly normal to 
see it in code that way, so it's not confusing. And since you're not going to 
try to enumerate over such enums, it's not like they cause any real confusion 
with "normal" enums.

You can think of it a bit like static. Static is used for different things in 
different contexts (even though most contexts are quite similar - IIRC, there's 
a 
way to define static in C++ which fits all of its uses in C++, though D adds 
some 
more that don't fit that definitition), but it doesn't really cause any 
confusion. 
enum is the same way. Sure, from the standpoint of language purity, manifest 
constants shouldn't be declared using enum, but the reality of the matter is 
that it works just fine.

- Jonathan M Davis

Reply via email to