enum values without initializer
Daniel Keep
daniel.keep.lists at gmail.com
Tue Apr 6 08:03:43 PDT 2010
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.
More information about the Digitalmars-d-learn
mailing list