--- Damian Conway <[EMAIL PROTECTED]> wrote:
> Note that converting to and from C<undef> in numeric contexts is much
> less troublesome in Perl 6, because the C<//> operator makes it
> trivial to
> catch bad cases and handle them appropriately:
> 
>       @a[$str//0]     // silently convert to zero
>       @a[$str//die]   // silently convert to exception

Good point. When it's this simple to avoid the warning, the warning
should stay on by default.

> 
> >> What about @a[NaN]?  Just another warning probably.
> 
> Actually, I would expect it to throw an exception. Using something
> that is
> explicitly and deliberately *not* a number [*], in a context that
> expects a 
> number, almost certainly points to a serious problem in the code.

It's a sink. A data sink if we allow it, and a time sink if we discuss
it.

Given that NaN is, in fact, a "numerish" value (IOW: The context in
which NaN is meaningful is a numeric one) you could argue for allowing
storing into @a[NaN]. But you can't make a meaningful argument about
fetching from it.

Since NaN == NaN is false, how could you possibly retrieve any value
you earlier stored?

So it's either illegal, or legal but write-only.

=Austin

Reply via email to