Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion negative index in arrays
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stephen Rawls  
View profile  
 More options Aug 1 2002, 9:48 am
Newsgroups: perl.perl6.internals
From: steven3...@yahoo.com (Stephen Rawls)
Date: Thu, 1 Aug 2002 06:46:33 -0700 (PDT)
Local: Thurs, Aug 1 2002 9:46 am
Subject: negative index in arrays
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 already
handles the simple cases when the absolute value of
the index is less than the container size, but it does
no bounds checking beyound that.  For instance:
  new P0, .PerlArray
  set P0, 3

  set P0[0],1
  set P0[1],2
  set P0[2],3

  set I0, P0[-1] #set I0 to 3
  set I0, P0[-10] #segfaults on my machine

My question: do we want the latter case to return an
error, or should we try to DTRT and in the above case
set I0 to 3.  All it takes is changing the if in all
the lines like:
if (ix < 0) ix += SELF->cache.int_val

to a while.  I just wanted to see what the general
consensus is, since I want the Tuple pmc to do the
same thing in this respect as the PerlArray pmc.

Thanks!
Stephen Rawls

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.