On Tue, Apr 06, 2010 at 08:47:11PM -0700, Geoffrey Broadwell wrote:
: First: what Damian said.
: Second: Whatever syntax people come up with has to make it easy and
: type-safe to name particular combinations of those bits.
: In other words, you should be able to make a bitset with Unix-style
You use that word 'bitset', but real sets would be better, if they
can also behave like bitsets at need.
: But still be able to make bitmasks (ignore the syntax here):
: OTHER_MASK = OTHER_READ +| OTHER_WRITE +| OTHER_EXECUTE;
: GROUP_MASK = GROUP_READ +| GROUP_WRITE +| GROUP_EXECUTE;
: These bitmasks should be properly typed with respect to the original
: bitset; which is to say, this should work:
: my Permissions $other_perms = $file_perms +& OTHER_MASK;
Well, I suppose we could do violence to the operator and overload
it between set types, but I think of +& as a coercion to numeric
types, with a return of a number, not a set. So I think, as I
mentioned in my other message, that it would be good to stay
away from the numeric bitops if you really want type safety.
What you're really wanting is more like:
my Perms $other_perms = $file_perms ∩ $interesting_perms;
or more Texasly:
my Perms $other_perms = $file_perms (*) $interesting_perms;
in which case the intersection returns a set, not a number.
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.
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.