Re: enum values without initializer
bearophile wrote: Nick Sabalausky: If you don't want that doplication you can also write: enum auto f = Foo(); Can't you do: enum f = Foo(); ? In my opinion that's a semantic mess, I don't write that. auto is for automatic local type inference and enum is to ask for a compile time constant. No it isn't. 'auto' is a storage class, it has NOTHING to do with type inference. Type inference is triggered when the type is omitted from a declaration. It just turns out that in the majority of cases (variables), the easiest way to do this is to use the default storage class which is used if you don't otherwise specify one: auto. This is why 'const blah = 42;' works: const is used as a storage class and the type is omitted.
Re: enum values without initializer
Nick Sabalausky: If you don't want that doplication you can also write: enum auto f = Foo(); Can't you do: enum f = Foo(); ? In my opinion that's a semantic mess, I don't write that. auto is for automatic local type inference and enum is to ask for a compile time constant. Bye, bearophile
Re: enum values without initializer
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
Re: enum values without initializer
bearophile bearophileh...@lycos.com wrote in message news:hp8jra$1ln...@digitalmars.com... If you don't want that doplication you can also write: enum auto f = Foo(); Can't you do: enum f = Foo(); ?