Re: negative index in arrays

2002-08-01 Thread Aldo Calpini
Stephen Rawls wrote: > since I want the Tuple pmc to do the same thing in > this respect as the PerlArray pmc. just my opinion, but I don't want this. it would be PerlTuple then. let's keep this stuff at a higher level. the only and one reason I see because one would implement tuples instead of

Re: negative index in arrays

2002-08-01 Thread Stephen Rawls
--- Aldo Calpini <[EMAIL PROTECTED]> wrote: > there should also be no need to check for > syntactic sugar like negative indices. True, I suppose if a language REALLY wanted this, it could be implemented on the interpreter level. Also of note, instead of having TUPLE1 + TUPLE2 act as arrays, and

Re: negative index in arrays

2002-08-01 Thread Dan Sugalski
At 6:46 AM -0700 8/1/02, Stephen Rawls wrote: >In working on the Tuple pmc (almost done!) I've come >accross a small semantic problem. I suppose this >might be language level (and thus Larry's turf?), but >how should the VM handle negative indecis? It should pass them on to the PMC directly, whi

Re: negative index in arrays

2002-08-01 Thread Stephen Rawls
> It should pass them on to the PMC directly, which > should then handle them properly. Let me rephrase. How should the PerlArray pmc handle negative indecis when the absolute value of the index is greater than the size of the array. Here are some examples: #first set up an array new P0, .Per

Re: negative index in arrays

2002-08-01 Thread Sean O'Rourke
On Thu, 1 Aug 2002, Stephen Rawls wrote: > > It should pass them on to the PMC directly, which > > should then handle them properly. > > Let me rephrase. How should the PerlArray pmc handle > negative indecis when the absolute value of the index > is greater than the size of the array. IMHO it

Re: negative index in arrays

2002-08-01 Thread Graham Barr
On Thu, Aug 01, 2002 at 02:11:27PM -0700, Stephen Rawls wrote: > > It should pass them on to the PMC directly, which > > should then handle them properly. > > So, if ix < -SELF->cache.int_val then the code tries > to use a negative value to access the array element in > the C code. This is obvi

Re: negative index in arrays

2002-08-01 Thread Stephen Rawls
--- Sean O'Rourke <[EMAIL PROTECTED]> wrote: > > Let me rephrase. How should the PerlArray pmc > > handle negative indecis when the absolute value of > > the index is greater than the size of the array. > > IMHO it would be most consistent with the way > autovivification of positive indices work

Re: negative index in arrays

2002-08-01 Thread Dan Sugalski
At 2:32 PM -0700 8/1/02, Stephen Rawls wrote: >--- Sean O'Rourke <[EMAIL PROTECTED]> wrote: >> > Let me rephrase. How should the PerlArray pmc >> > handle negative indecis when the absolute value of >> > the index is greater than the size of the array. >> >> IMHO it would be most consistent w

Re: negative index in arrays

2002-08-01 Thread Sean O'Rourke
On Thu, 1 Aug 2002, Dan Sugalski wrote: > No, I don't think this is appropriate. The PerlArray class implements > Perl arrays, and should implement their semantics. It implements Perl 6 arrays, though. If it's a useful semantic extension (restrictions are another matter), I don't see why "perl 5

Re: negative index in arrays

2002-08-01 Thread Stephen Rawls
--- Dan Sugalski <[EMAIL PROTECTED]> wrote: >> [snip] > No, I don't think this is appropriate. The PerlArray > class implements > Perl arrays, and should implement their semantics. Let me rephrase again :) What should the semantics for Perl arrays be? cheers, Stephen Rawls ___

Re: negative index in arrays

2002-08-01 Thread Dan Sugalski
At 10:24 PM +0100 8/1/02, Graham Barr wrote: >On Thu, Aug 01, 2002 at 02:11:27PM -0700, Stephen Rawls wrote: >> > It should pass them on to the PMC directly, which >> > should then handle them properly. >> >> So, if ix < -SELF->cache.int_val then the code tries >> to use a negative value to a

Re: negative index in arrays

2002-08-01 Thread Dan Sugalski
At 2:54 PM -0700 8/1/02, Sean O'Rourke wrote: >On Thu, 1 Aug 2002, Dan Sugalski wrote: >> No, I don't think this is appropriate. The PerlArray class implements >> Perl arrays, and should implement their semantics. > >It implements Perl 6 arrays, though. If it's a useful semantic extension >(res

Re: negative index in arrays

2002-08-01 Thread Graham Barr
On Thu, Aug 01, 2002 at 05:42:12PM -0400, Dan Sugalski wrote: > At 10:24 PM +0100 8/1/02, Graham Barr wrote: > >On Thu, Aug 01, 2002 at 02:11:27PM -0700, Stephen Rawls wrote: > >> > It should pass them on to the PMC directly, which > >> > should then handle them properly. > >> > >> So, if ix <

Re: tuple algebra (was: negative index in arrays)

2002-08-01 Thread Aldo Calpini
Stephen Rawls wrote: > Also of note, instead of having TUPLE1 + TUPLE2 act as > arrays, and return the sum of their sizes, I am > treating it like this: (a1, a2, ... , an) + (b1, b2, > ... , bn) = (a1 + b1, a2 + b2, ... , an + bn) makes sense to me (and certainly adds some spice to the cause of t

Re: tuple algebra (was: negative index in arrays)

2002-08-01 Thread Stephen Rawls
--- Aldo Calpini <[EMAIL PROTECTED]> wrote: > you should also consider the case TUPLE1 + 5 which > should return (a1 + 5, a2 + 5, ... , an + 5). Agreed. I had started to implement this already, but I've only done the add function so far, since I'm still testing and waiting for a consensus. >