PhobosWatch: manifest => enum

Bruce Adams tortoise_74 at yeah.who.co.uk
Sat Dec 29 04:34:15 PST 2007


On Sat, 29 Dec 2007 08:36:07 -0000, Janice Caron <caron800 at googlemail.com>  
wrote:

> On 12/29/07, Don Clugston <dac at nospam.com.au> wrote:
>> Does this compile?
>>
>> enum : cfloat { A=2, B, C }
>
> Even more interestingly, what about
>
>     enum : ifloat { a = 2i, b };
>
> If b has to equal (a+1), then there is no way it can be the same type as  
> a.

I think Doug's arguments are the must compelling yet.
However, just to play Devil's advocate with your complaint about proper  
enumerations.
What if rather than being +1. The successor operation was always  
opIncrement and what if
opIncrement could be implemented as a free function extending even builtin  
types. E.g.

ifloat opIncrement(ifloat this)
{
   return this+1i;
}

I'm not sure if the conference proposal of using free functions to extend  
classes went
as far as allowing operators to be declared this way but I don't see why  
it shouldn't.



More information about the Digitalmars-d mailing list