enum

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Apr 11 11:14:36 PDT 2014


On 4/11/14, 5:22 AM, Steven Schveighoffer wrote:
> 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

This is a most interesting idea! -- Andrei



More information about the Digitalmars-d mailing list