On Thu, Aug 08, 2002 at 03:28:18PM -0400, Dan Sugalski wrote: > At 11:00 AM -0700 8/8/02, Steve Fink wrote: > >Oh, yeah. The perl6 summary reminded me: I forgot to mention that this > >would also make $a[-6] (or @a[-6] if you're writing perl6) on a > >4-element array throw an exception instead of autoextending the array, > >wrapping around to a valid element, or exploding in flames. That goes > >for both Array and PerlArray. I don't remember what the currently > >checked-in version does. > > Array and PerlArray shouldn't autoextend that way, I think. I'm not > 100% sure that Array should auto-extend at all--I think I'd rather it > didn't. We need to check with Larry as to whether PerlArrays should > autoextend when using excess negative indices.
I don't think I was explaining myself very clearly. The patch implements exactly what you want. No autoextension of any kind for Array. Both Array and PerlArray throw an exception for the @a[-6] case (I'll change it again if Larry says it should do something else, but it's clearly better than the current behavior, which is to dump core.) Personally, I think if it runs out of elements because of a too-negative index, it should pick another array to walk through next. If the magnitude is still too large, keep scanning through more until you run out of arrays. If you're *still* going, scan the process table to find other instances of perl that you can look through. Either that, or autoextend the size of the array to be negative -- if the size is -N, you just ignore the next N values pushed.