At 12:11 PM -0800 1/30/07, [EMAIL PROTECTED] wrote:
Disabled negative subscript dwimmery for all shaped arrays.
* can now take + and - operators.

At 2:54 PM -0800 1/30/07, Jonathan Lang wrote:
Could we get a single-character symbol that could be used in an array
index to refer to its shape in a dwimmy way?  Something like:

 @x[*.tail] # equivalent to @x[*]
 @A[*.head+2, *.tail-1]

(where head and tail are methods of the shape that return the current
dimension's start and end points.)

In a related fashion ...

I'm thinking it may be better to just get rid of negative subscript dwimmery entirely, eg "@foo[-1]", and use things like "@foo[*.head]" and "@foo[*.tail]" instead to refer to the first and last elements.

That solution is a lot more self-describing, leads to better consistency between shaped and unshaped arrays, and is easy to learn for both Perl 5 people and people coming from other languages.

Also importantly, it should prevent common types of errors.

If being more terse is important, you could further abbreviate .head and .tail, but the main point is that a plain -N array index never means count from the end.

-- Darren Duncan

Reply via email to