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] # <def> (warning: index out-of-bounds)
@a[2**128] # <def> (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] # <def> (warning: index out-of-bounds)
@a[-Inf] # EXCEPTION: can't use -Inf as array index

Where <def> is whatever the type-specific default is, typically C<undef>, 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

Reply via email to