On Wed, Nov 09, 2005 at 01:45:21PM +0100, TSa wrote:
: So, why not call the thing what it is---a set *type* declarator!
:
: set SmallInt of Int where { abs < 10 };
:
: set SomeNums of Num = (3.14, 4, 89, 23.42);
:
: set Bit of Int = (0,1);
Interesting idea. I expect a bit of interference from the verb
"to set", but that's probably not a showstopper, particularly since
the next token isn't a variable.
: Enumerations are then just sets of pairs
:
: set NumWords of Pair = { zero => 0, one => 1, two => 2, three => 3 };
: # or with ( ... ) instead?
:
: enum NumWords = <zero one two three>; # short form of the above
:
:
: Without the 'of' it doesn't look so good
:
: set Num SomeNums = (3.14, 4, 89, 23.43);
:
: but OTOH, it looks nicely like
:
: my Num @SomeNums = (3.14, 4, 89, 23.43);
:
: my Int %NumWords = { zero => 0, one => 1, two => 2, three => 3 };
:
: YMMV, though ;)
I'd like to lose the = if possible. We don't say
sub foo = { ... }
: Does that work? Perhaps even while maintaining compatibility with the
: set *value* creator sub that exists in Pugs, IIRC?
:
: my $x = set( 1, 2, 3 ); # $x contains a set reference at best
They can perhaps be unified, especially if we lose the = noise. Probably
have to require the parens syntactically though, just as though you'd said
my $x = my($a,$b,$c);
Larry