enum values without initializer
bearophile
bearophileHUGS at lycos.com
Sat Apr 3 16:43:38 PDT 2010
BCS :
> #1 is a bad idea as are almost all special case rules
Right, I was not looking for a special case.
> #2 is just flat wrong 99.9% of the time.
I see. Then I will think if it's right to remove that "bug" report or not.
----------------
>I have to ask. :) What does that code supposed to mean? Is Foo the base type of the enum, so that we can create enum values for user types as well?<
In D2 Walter has decided to use the keyword "enum" to represent what in D1 is "const". So that's not an enumeration at all, it's just a constant.
With other people I think it's a bad choice to use "enum" to say "const", but I think it's one of small warts of D2 that will not change...
That code just means that I want to create a compile-time const value initialized at its default (init). But it's not correct current D2 code, you have to write:
struct Foo {}
enum Foo f = Foo();
void main() {}
If you don't want that doplication you can also write:
enum auto f = Foo();
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list