Damian Conway wrote:
> I do like the idea of being able to specify the sequence of values of an
> enumeration by using a series of some kind.
>
> And I must say the one that feels most natural is the one that plays on
> the equivalence of underlying equivalence of enums and constants, namely:
>
> enum Perms <Read Write Exec Fold Spindle Mutilate> = 1,2,4...*;
>
> This would also mean you could think of a "normal" enum:
>
> enum Days <Sun Mon Tue Wed Thu Fri Sat>;
>
> as simply defaulting to C< = 1...* >.
Wouldn't that be C< = 0...* >?
That said, don't we already have a means of assigning specific values
to individual members of an enum? I forget the exact syntax, but I
believe that it involves an assignment operator within the
enumeration. Mind you, this is from memory:
enum Perms { Read = 1, Write = 2, Exec = 4, Fold = 8, Spindle =
16, Mutilate = 32 }
...or something to that effect. Clumsy, sure; but it seems to me that
this is exactly the sort of thing that hyper-operators were designed
to handle:
enum Perms { Read, Write, Exec, Fold, Spindle, Mutilate } »=« (1,
2, 4 ... 32)
enum Perms { Read, Write, Exec, Fold, Spindle, Mutilate } »=» (1,
2, 4 ... *)
...or something along those lines. I'll check the exact syntax later,
when I have more time; but I wonder if something to this effect is
already possible with the language spec as written.
--
Jonathan "Dataweaver" Lang