PhobosWatch: manifest => enum
Walter Bright
newshound1 at digitalmars.com
Sun Dec 30 12:43:01 PST 2007
Derek Parnell wrote:
> On Sun, 30 Dec 2007 11:27:17 +0000, Janice Caron wrote:
>
>> On 12/30/07, Bastiaan Veelo <Bastiaan at veelo.net> wrote:
>>> If not, that would be confusing to me, as you will
>>> be able to switch on some enums but not on others.
>> You can't switch on an anonymous enum. Anonymous enums have no type,
>> and therefore it is not even /possible/ to generate an expression
>> whose type is that of an anonymous enum!
>>
>> So switch/case survives unharmed.
>
> And yet this compiles and runs ...
>
> // -------------
> import std.stdio;
>
> enum
> {
> one = 1,
> two = 2,
> three = 3
> }
>
> void main()
> {
> auto x = three;
>
> switch (x)
> {
> case one: writefln("ONE"); break;
> case two: writefln("TWO"); break;
> case three: writefln("THREE"); break;
> }
> }
Yes, and x is of type int, not anonymous enum.
More information about the Digitalmars-d
mailing list