Larry Wall <[EMAIL PROTECTED]> writes:

> 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.

  If '*' is already going to be a special term when expecting an array
index, I could imagine using it also as a term for the end of the
array -- which end depending on whether it is used in addition or
subtraction.

my int @ints is shape(-10..10;0..3);

@ints[*+0;*-0] =:= @ints[-10;3];

  (Though I cannot see any reason why I would want to use something
like that, I am sure someone somewhere would find it useful ...)

> 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... :-)

  A _little_ shorter, okay?  If @ints.shape[0] is a range, then:

my int @ints is shape(-10..10;0..3);
@ints.shape[0;0] == -10;
@ints.shape[0;-1] == 10;

  Assuming shape has the proper shape, that is.  :-)

  And, in scalar context, it would still return the size.

my int @ints is shape(-10..10;0..3);
@ints.shape[0] == 21;

  ... now, I don't know if I mean that seriously.  You be the judge.  :-)


Eirik
-- 
-------- Rule of Feline Frustration: -------* I bet you never noticed that
When your cat has fallen asleep on your lap | "homeowner" has the word    
and looks utterly content and adorable, you | "meow" in the middle of it. 
will suddenly have to go to the bathroom.   *-------------  P. McGraw ----

Reply via email to