enum abuse
Steven Schveighoffer
schveiguy at yahoo.com
Sun Mar 2 12:25:21 PST 2014
On Sat, 01 Mar 2014 00:39:23 -0500, Meta <jared771 at gmail.com> wrote:
> On Friday, 28 February 2014 at 19:09:06 UTC, Steven Schveighoffer
> wrote:
>> For a *VERY* short time (I think one version perhaps), we had the
>> 'manifest' keyword which was supposed to mean manifest constant.
>>
>> It was removed, Andrei was a very stanch supporter of enum being the
>> manifest constant keyword. This comment in an early debate about what
>> became the inout feature is pretty explanatory:
>> https://d.puremagic.com/issues/show_bug.cgi?id=1961#c3
>>
>> "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."
>>
>> -Steve
>
> Hmm, I didn't know that. Interesting. I think this was a mistake
> on Andrei's part, though. The concept of enumerations doesn't
> have anything to do with evaluating an expression at compile time
> other than how it's implemented in D and C++, so overloading the
> keyword to mean "evaluate this expression at compile time" does
> not seem like a good choice.
I think it's not so much that enum doesn't always mean "enumeration" in D,
it doesn't in C or C++ either. It can be used to define bitfields,
whatever.
The point I think Andrei was trying to make is that enum in C and C++ does
what we want, we just need to extend the types it works with. To change
the name of enum would be catastrophic for existing D and C code, and to
create a new name for something so totally similar would be bikeshedding.
-Steve
More information about the Digitalmars-d-learn
mailing list