On Fri, 2004-09-03 at 20:08, Larry Wall wrote:
> Arrays with explicit ranges don't use the
> minus notation to count from the end. We probably need to come up
> with some other notation for the beginning and end indexes. But it'd
> be nice if that were a little shorter than:
>
> @ints.shape[0].beg
> @ints.shape[0].end
>
> Suggestions? Maybe we just need integers with "whence" properties... :-)
Actually, what you had in Perl 5, was essentially:
$x[-1] == reverse(@x)[0]
In Perl 6, this is actually workable because of the lazy evaluation of
reverse, so if you simply re-name reverse to "rev" as a list method for
brevity:
my int @ints is shape(-10..10);
@ints.rev[-10]; # assuming that @x.rev retains shape
And as someone pointed out:
@ints.abs.rev[0]
if you had an abs that strips away shape.
All that being said, I think that this (shape) is a dangerous idea at
best. If used, it should probably specify a length ONLY:
my int @ints is shape(10)
and in that light, I think it would best be renamed to "length" or
"extent".
Specifying the origin should be left to $[... that is, left out.
--
â 781-324-3772
â [EMAIL PROTECTED]
â http://www.ajs.com/~ajs