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
- Re: More Array Behaviors Austin Hastings
- Re: More Array Behaviors Nicholas Clark
- Re: More Array Behaviors Austin Hastings
- Re: More Array Behaviors Andrew Wilson
- Re: More Array Behaviors Luke Palmer
- Re: More Array Behaviors Michael Lazzaro
- Re: More Array Behaviors John Williams
- Re: More Array Behaviors Michael Lazzaro
- Re: More Array Behaviors Damian Conway
- Re: More Array Behaviors Austin Hastings
- Re: More Array Behaviors (Take 2) Michael Lazzaro
- Re: More Array Behaviors (Take 2) Dan Sugalski
- Re: More Array Behaviors (Take 2) Michael Lazzaro
- Re: More Array Behaviors (Take 2) John Williams
- Re: More Array Behaviors (Take 2) Damian Conway
- Arrays: Default Values Michael Lazzaro
- Re: Arrays: Default Values Jonathan Scott Duff
- Re: Arrays: Default Values Jonathan Scott Duff
- Re: Arrays: Default Values Austin Hastings
- Re: Arrays: Default Values Austin Hastings
- Re: Arrays: Default Values Damian Conway