Re: More Array Behaviors (Take 3)

2003-01-28 Thread Leopold Toetsch
Michael Lazzaro wrote:


2) There is NO platform-dependent maximum array size.  If it's not a 
sparse array, you'll run out of memory long before you run out of 
indexes, but using bigints as indexes for sparse arrays is OK.


Current: array size is limited to $arch's +INTVAL (2^31-1 / 2^63-1).
Arrays get sparse by default if you set arrays elements with indices 
distance > ~3K.

IMHO if you need bigger indices use a hash.


MikeL


leo




Re: More Array Behaviors (Take 3)

2003-01-28 Thread Damian Conway
Michael Lazzaro wrote:


Where  is whatever the type-specific 

...or user specified...


default is, typically C, C<0>, or C<''>.


Damian




More Array Behaviors (Take 3)

2003-01-28 Thread Michael Lazzaro

Corrected in accordance with design team member feedback.  These should 
be solid, now.  Thanks much for the responses.

1) Edge cases in array indexing:

my @a = (1,2,3);

@a[0] # 1
@a[1] # 2
@a[2] # 3
@a[3] #   (warning: index out-of-bounds)
@a[2**128]#   (warning: index out-of-bounds)
@a[ Inf ] # EXCEPTION: can't use +Inf as array index
@a[ undef ]   # 1  (warning: undefined index)
@a['foo'] # 1  (warning: non-numeric index)
@a[ NaN ] # EXCEPTION: can't use NaN as array index

@a[-1]# 3
@a[-2]# 2
@a[-3]# 1
@a[-4]#   (warning: index out-of-bounds)
@a[-Inf]  # EXCEPTION: can't use -Inf as array index

Where  is whatever the type-specific default is, typically 
C, C<0>, or C<''>.

2) There is NO platform-dependent maximum array size.  If it's not a 
sparse array, you'll run out of memory long before you run out of 
indexes, but using bigints as indexes for sparse arrays is OK.

MikeL