On Tue, Apr 06, 2010 at 10:19:15PM -0700, Damian Conway wrote:
: Larry concluded:
: > I do freely admit that most Perlfolk are not used to thinking of
: > permissions in terms of set theory. But as I said, we're looking at
: > kind of a strange use case here, and perhaps not typical of the kinds
: > of sets of small numbers that people will be using in the future.
: The reason I raised the issue is because I believe it *is* a very
: typical use-case...in certain hardware-oriented domains.
: > I kinda hope we can get a bit further away from the machine code
: > level of reality one of these decades. Perl 6 should not be
: > optimized for C semantics.
: Agreed. But it should at least support those who need to work at
: the machine code level, but would prefer not to have to do so in C.
: That said, I'd be perfectly happy to encourage the use of proper set
: abstractions for this purpose, so long as the long-suffering hardware
: engineers can still easily convert the final set to an appropriate
: bit-pattern when it's time to pump the results out to the hardware.
Another possibility would be to go ahead and have the numbers be
powers of two, but have the sets smart enough about *those* rather
than the small integers. Then we'd need some kind of sugar like
enum Perms of (1,2,4...*) <Read Write Exec>;
or with a more constant-declaring-like syntax:
enum Perms <Read Write Exec> = 1,2,4...*;
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. We've
got these silly series operators; it seems a shame not to use them
for powers of two when appropriate.