2 problems I can't get my head around

Timon Gehr timon.gehr at gmx.ch
Mon Nov 26 07:04:38 PST 2012


On 11/26/2012 02:01 PM, Paulo Pinto wrote:
> On Monday, 26 November 2012 at 12:40:06 UTC, Andrej Mitrovic wrote:
>> On 11/26/12, Manu <turkeyman at gmail.com> wrote:
>>> 1.
>>>
>>> enum i = 10;
>>> pragma(msg, is(i == enum) || is(typeof(i) == enum)); // <- false?!
>>>
>>> I can't find a way to identify that i is an enum, not a variable; can
>>> not
>>> be assigned, has no address, etc.
>>
>> It's not an enum, it's a manifest constant.
>
> This is one issue I have with D's enums, they look like C++ constant
> tricks instead of proper enumerations.
>


enum Numbers{
     Zero,
     One,
     Two,
     Three,
}

> Everytime I see just code, I always think why const is not used instead.
>

Because 'const' already denotes 'readonly'. :o)



More information about the Digitalmars-d mailing list