Larry Wall wrote:

On Fri, Sep 03, 2004 at 05:45:12PM -0600, John Williams wrote:
: What happens when the Pascal programmer declares
: : my int @ints is shape(-10..10);
: : Does it blow up?


No.

: If not, does  @ints[-1]  mean the element with index -1 or the last element?

The element with index -1.  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... :-)

Larry

What jumps to my mind is that inside an array subscript could be (sub)?context of it's own. Then one could do:

@ints[.beg .. .end ; .beg + 3 .. .end];

Where the .beg and .end would relate to @ints.shape[0] or @ints.shape[1] depending on which position it's in.

My only issue with this, and why I refered to it as a possible subcontext, is that it's easy to concieve of somewanting to use the prior context to generate the subscripts for an array.


The other idea which jumps to mind was to create an operator which tell the compiler to treat the the following number as if it referred to a 0-based (sub)array, and negatives count off the end. What springs to my mind is that we are saying this is the "relative to start / end" of the range, so I will call it Î (capital delta).


@ints[ Î0 .. Î-1 ; Î3 .. Î-1 ];

It at least looks nice.

-- Rod

Reply via email to