Implicit enum conversions are a stupid PITA

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Mar 28 15:48:12 PDT 2010


On 03/27/2010 09:02 AM, Simen kjaeraas wrote:
> Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>
>> alias Flags!(ubyte, "do_nothing",
>> "walk_dog"
>> "cook_breakfast"
>> "deliver_newspaper"
>> "visit_miss_kerbopple"
>> "wash_covers") Todo;
>>
>> I encourage you to code that up and see how it swims. We need to stop
>> inventing syntax for any single thing that seems useful, and start
>> eating our dogfood. If our mechanism for code generation is not good
>> enough, we should improve it, not generate by hand ever new constructs.

[snip implementation]

Looks good, but there are a couple of things I'm worried about. One is 
that it generates many templates (as opposed to CTFE). But that's an 
implementation detail. What I think this is lacking is the ability to 
predefine flags that are a combination of other flags. For example, some 
file open flags could define DEFAULT_READ as READ|SHARED. I'm not sure 
how to express that.

Andrei



More information about the Digitalmars-d mailing list