Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Daniel Ruoso
Em Ter, 2010-04-06 às 22:19 -0700, Damian Conway escreveu: 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

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Damian Conway
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

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Damian Conway
Daniel Ruoso pointed out: Using bitsets in Perl 6 is just as easy as using in Perl 5 -- which happens to be the same as using in C, but it's not C... constant PERM_WRITE = 0b0001; constant PERM_READ = 0b0010; constant PERM_EXEC = 0b0100; constant PERM_NAMES = { PERM_WRITE = 'Write',

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Jon Lang
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

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Larry Wall
On Wed, Apr 07, 2010 at 06:33:46AM -0700, Jon Lang wrote: : 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

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Damian Conway
Jonathan Lang wrote: Wouldn't that be C = 0...* ? Indeed. Thanks for the correction. That said, don't we already have a means of assigning specific values to individual members of an enum?  I forget the exact syntax, The exact syntax is: enum Perms [Read = 1, Write = 2, Exec = 4, Fold

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Damian Conway
We could make enum declarators even more like constant declarators by using a pseudo assignment.  Then we could use = instead of parens:    enum Perms = Read Write Exec Fold Spindle Mutilate Z= 1,2,4...*; Hmm. That doesn't seem very like constant declarators. In a constant declarator, the

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread yary
2010/4/6 Larry Wall la...@wall.org:    Set(Read | Write)   # bogus, R|W is really 3 sets, R, W, and RW!    Set(Read Write)   # okay, can only represent RW Set(A | B) doesn't seem so bogus to me, if what you want is the power set- not the original posters intent, but reasonable in other

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Brandon S. Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Apr 7, 2010, at 00:52 , Larry Wall wrote: more syntactic and/or semantic sugar. It's just a bit awkward, after you say: enum Permissions Read Write Exec; subset Perms of Set of Permissions; that the name of the single-member sets are

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Martin D Kealey
On Wed, 7 Apr 2010, yary wrote: 2010/4/6 Larry Wall la...@wall.org:    Set(Read | Write)   # bogus, R|W is really 3 sets, R, W, and RW!    Set(Read Write)   # okay, can only represent RW Set(A | B) doesn't seem so bogus to me, if what you want is the power set Hmm, surely a power-set

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-07 Thread Jon Lang
One more idea: could you implement the sort of thing being asked for by means of a buffer? That is, what's the difference between the bitset being asked for and a Buf[boolean]? And could those differences be addressed by composing a Buf[boolean] into a more appropriate role? Note also that Perl

A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-06 Thread Damian Conway
An issue came up in a class I was teaching today... There doesn't seem to be an easy way to create a type that allows a set of enumerated bit-flags *and* all the combinations of those flags...and nothing else. For example: enum Permissions ( Read = 0b0001, Write = 0b0010, Exec = 0b0100 );

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-06 Thread Geoffrey Broadwell
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 permissions: OTHER_EXECUTE OTHER_WRITE OTHER_READ

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-06 Thread Larry Wall
On Tue, Apr 06, 2010 at 08:31:24PM -0700, Damian Conway wrote: : An issue came up in a class I was teaching today... : : There doesn't seem to be an easy way to create a type that allows a set : of enumerated bit-flags *and* all the combinations of those flags...and : nothing else. : : For

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-06 Thread Damian Conway
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

Re: A common and useful thing that doesn't appear to be easy in Perl 6

2010-04-06 Thread Larry Wall
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