March 01, 2014
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.
March 01, 2014
On Saturday, 1 March 2014 at 05:39:24 UTC, Meta wrote:
> 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

It doesn't.

enum x = expression;

is the same as

enum
{
     x = expression
}

and minding this trivial rewrite, it generally acts in exactly
the same way as C++ and other languages (plus D's CTFE
capabilities, naturally).

That the compiler has to fully evaluate the expression, CTFE
included, to calculate the value of x, is an obvious consequence
of enum semantics.
March 02, 2014
On Sat, 01 Mar 2014 00:39:23 -0500, Meta <jared771@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
1 2
Next ›   Last »