enum

Steven Schveighoffer schveiguy at yahoo.com
Fri Apr 11 05:22:01 PDT 2014


On Thu, 10 Apr 2014 15:22:35 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 4/9/14, 9:47 PM, Walter Bright wrote:
>> On 4/9/2014 5:39 PM, Jonathan M Davis wrote:
>>> On Wednesday, April 09, 2014 14:14:21 Andrei Alexandrescu wrote:
>>>> One wants to call a function taking such an enum. -- Andrei
>>>
>>> But it _isn't_ going to be a valid enum value. IMHO, a function which  
>>> is
>>> taking or-ed flags where those flags are enums needs to take uint or
>>> ulong or
>>> whatever the base type of the enum is and _not_ the enum type.
>>
>> It makes perfect sense if you think of an enum as an integral type, some
>> values of which have names, as in the "Color" example I posted earlier.
>
> Problem is you think of it like that in a subset of cases only. FWIW I  
> wouldn't have advocated for final switch if that was the fostered view.

Idea just came to me. What about notifying the compiler which enums can be  
used in final switches (and perhaps should be more stringent in allowing  
math operations):

final enum name { ... }

-Steve


More information about the Digitalmars-d mailing list