>>>>> "BL" == Bart Lateur <[EMAIL PROTECTED]> writes:
BL> @bar = @foo[(1,2,3)];
BL> is the same as
BL> @bar = (@foo[1], @foo[2], @foo[3]);
BL> or: just an ordinary slice. OTOH,
BL> $bar = @foo[(1, 2, 3)];
BL> is the same as
BL> $bar = (@foo[1], @foo[2], @foo[3]);
the real problem with perl slices is that there is no special syntax
associated with the array/hash that is parse specially as a slice. so
you can't use 3 .. -1 to get what you want. .. is just an expression
operator and perl doesn't see it as a slice case and DWIM instead of
simply expanding the list. IIRC python has a 3:-1 syntax for use only in
arrays that does a logical slice the way we want. but that limits a
slice to a single range which is also limiting.
now, you have two separate slice issues, contiguous and discontiguous
and they probably can't have the same syntax. if we want to support -1
and friends indexing from the right side of a list/array, then the slice
syntax needs to know that and .. won't work by doing its nromal thing.
so we have to get some way to denote a list of indices as a slice and
also support some range operation as a possible component of that list
with the knowledge that the range arguments are also indices and not
just integers.
i don't have any syntax ideas for this at the moment.
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html