PhobosWatch: manifest => enum

Janice Caron caron800 at googlemail.com
Sat Dec 29 07:13:53 PST 2007


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).

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.

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!)




More information about the Digitalmars-d mailing list