On Monday, January 27, 2003, at 11:46  AM, John Williams wrote:
On Mon, 27 Jan 2003, Michael Lazzaro wrote:
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.
It's certainly a legitimate question. (I'm not sure that @a[undef] == @a[0] is the correct behavior, going forward. It certainly can be error-prone.)

We need an expert decision here, please.

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)

What about @a[NaN]?  Just another warning probably.
Probably. After all, 'foo' in a numeric context should probably be... um... NaN. Or did we ever decide on that one, after discussing it into the ground?

MikeL

Reply via email to