Feature request: Attribute with which to enable the requirement of explicit-initialization of enum variables
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sun Jun 2 19:57:28 PDT 2013
On 6/3/13, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> Machine machine;
>
> if(something)
> {
> // do a bunch of stuff
> machine = Machine.x86;
> }
> else
> {
> //do a bunch of other stuff
> machine = Machine.x86_64;
> }
>
> you'd be forcing people to directly initialize the machine variable even if
> they didn't intend to use the value.
I'd hope in that case the compiler would be smart enough to realize
the variable is indeed initialized before use, and would avoid the
compiler error.
On 6/3/13, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> This is like how Java forces you to directly initialize things when it doesn't
> think that you've initialized them elsewhere. D did _not_ take that route. It
> when with have an init value for every type and initializing with that.
Yes, but we do have float.init which is NaN. We don't have the
equivalent for enums.
More information about the Digitalmars-d
mailing list