On Mon, 27 Jan 2003, Michael Lazzaro wrote:

> Some requests for verification, plus additional questions.  If anyone
> has any arguments/clarifications/questions on these, please discuss so
> I can document.
>
> 1) Edge cases in array indexing:
>
>      @a[ undef ]   # undef, or 1?
>      @a['foo']     # undef, or 1?

These should generate warnings, at least.

I don't know whether undef or 1 is more correct.

Perl5 chooses 1, but it's smart enough to distiguish between $a["1e0"]
(returns 2) and $a["1e"] (returns 1 and a non-numeric warning), so it's
definitely choosing to return $a[0] for non-numeric indexes.
(0+"1e" is 1, not 0)

> Is [undef] the same as [0] in Perl6?  Is there any index value you can
> give that will cause an exception?

What about @a[NaN]?  Just another warning probably.

~ John Williams


Reply via email to