Larry mused: > Alternatively, maybe there should be some way to express infinite sets. > Not sure I like the idea of an infinite junction, but something resembling: > > subset PowersOf2 of Int where any(1,2,4...*) > enum Perms of PowersOf2 <Read Write Exec>; > say Exec; # 4 > > Presumably the series in the junction would have to be sufficiently > monotonic so we can know when we've looked far enough. Or we just > allow something like one of: > > subset PowersOf2 is Set(1,2,4...*); > constant PowersOf2 = Set(1,2,4...*); > > In any case, the idea is that an enum of something like PowersOf2 would > be smart enough not to use values that aren't in the 'of' type.
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...* >. > We've got these silly series operators; it seems a shame not to use > them for powers of two when appropriate. I certainly agree there. Damian