We blitzed a discussion on #perl 3 minutes ago, reaching the conclusion that negated subscripts are cool.
So i was thinking:
subscripts are objects.
They are sets, really.
You can perform set operations on them:
[!-2]
is the subscript for everything but the second to last element.
By using a context enforcer (subscript [] ?, maybe since lists are
lazyy they can just be subscripts when used that way?) you can get a
subscript object, which you can then use in a subscript, and it
flattens out.
The set math is done by special casing junctions, perhaps?
my @array;
@array[$subscript];
@array[$other];
@array[$subscript | $other]; # union
@array[$subscript & $other]; # intersection
@array[!-1]; # -1 but false? this means that it's masking
my $not_1 = [!-1];
@array[$subscript & $not_1]; # subscript without -1
@array[$subscript | $not_1]; # subscript with -1, since it's a union
# with the complement of just -1
I've found myself replicating sets like these for accessing data
many a time in perl 5.
Maybe if refined this can be useful?
--
() Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418 perl hacker &
/\ kung foo master: /me wields bonsai kittens: neeyah!!!!!!!!!!!!!!!!
pgpgtuYOUpvBY.pgp
Description: PGP signature
