PhobosWatch: manifest => enum
Bastiaan Veelo
Bastiaan at Veelo.net
Sat Dec 29 14:17:58 PST 2007
Janice Caron wrote:
> On 12/29/07, "Jérôme M. Berger" <jeberger at free.fr> wrote:
>> Those usages should be deprecated
>> in favor of another keyword that would allow them plus extra
>> functionality (e.g. manifest constants) while "enum" is relegated to
>> its proper usage. I believe anything else would be too confusing
>> (particularly to newcomers).
Yes, please!
> It would be /really/ cool if Walter just implemented everything as he
> suggested, except for deprecating the word "enum" and replacing it
> with "manifest" everywhere.
"manifest", if not "define" (my preference) or "pure".
> Then "enum" could be redeployed for true enumerations only. e.g.
>
> enum Primary { red, blue, green }
> Primary col = red;
> int x = col; /* ERROR */
> int x = cast(int)col /* STILL AN ERROR */
> col = 1; /* ALSO AN ERROR */
> col = cast(Primary)1; /* NOPE! */
>
> Primary col2 = col++; /* successor */
> assert(col2 = Primary.blue);
> if (col == col2) { /*...*/ }
> if (col < col2) { /*...*/ }
>
> enum { x = 2 }; /* ERROR */
> enum E { x = 2 }; /* ERROR */
> enum E : int { x }; /* ERROR */
>
> ...but it will never happen! (Sigh!)
Why not? It will break existing code, but given the length of these
threads, D users may be prepared to cope with it where it does...
Bastiaan.
More information about the Digitalmars-d
mailing list