OK, here are the answers so far -- or more accurately, strawman interpretations of those answers that should be objected to if they're wrong.

1) Edge cases in array indexing:

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

@a[0] # 1
@a[1] # 2
@a[2] # 3
@a[3] # undef (warning: index out-of-bounds)
@a[2**128] # EXCEPTION: index is above max allowed index
@a[ Inf ] # undef (warning: 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] # undef (warning: index out-of-bounds)
@a[-Inf] # undef (warning: can't use Inf as array index)


2) There is a platform-dependent maximum array size, ((2**32)-1 for 32-bit platforms.) Attempting to access an index outside that range throws an exception. Note that this applies to both 'real' and 'sparse' arrays.

If these are incorrect statements, please correct me.

---

The other two questions are less definitively answered, so far. I shall attempt to disambiguate them...

MikeL

Reply via email to