reddit discussion on article by bearophile
bearophile
bearophileHUGS at lycos.com
Thu Nov 17 15:53:22 PST 2011
Timon Gehr:
> Hmm. How would that work? A and B don't have an own type.
> Your program is equivalent to
>
> import std.stdio;
> enum A = 0;
> enum B = 1;
> void main() {
> writeln(B); // prints 1 because B is replaced with 1.
> }
Right, my mental model of nameless enums was very wrong. I was thinking of them more like symbols (all nameless enums aren't grouped under a common name).
> You could use mixins to automatically generate
> alias E.A A;
> alias E.B B;
> // ...
>
> for a given enumerated type.
Right, but I don't know if I will ever need this.
Bye and sorry,
bearophile
More information about the Digitalmars-d
mailing list