=== again (sorry)

Allen Wirfs-Brock Allen.Wirfs-Brock at microsoft.com
Thu Nov 13 18:01:43 PST 2008


Ugh, I guess I left out a couple breaks...

>-----Original Message-----
>From: es-discuss-bounces at mozilla.org [mailto:es-discuss-
>bounces at mozilla.org] On Behalf Of Allen Wirfs-Brock
>Sent: Thursday, November 13, 2008 6:00 PM
>To: Igor Bukanov; Waldemar Horwat
>Cc: Mark S. Miller; es-discuss
>Subject: RE: === again (sorry)
>
>Now that this is pointed out the case that bothers me is code that looks
>something like this:
>
>switch (num) {
>        case NaN: alert("NaN");
>        case +Infinity: case -Infinity: alert("Infinity");
>        default: alert("a fine old number");
>}
>
>The intent of the code is obvious and yet the NaN case is obviously a
>bug.  However, I suspect that very view JavaScript programmer even among
>those who understand what a NaN is realize that.
>
>I'd call this an attractive nuisance that should be fixed in the
>language specification, probably by changing switch to use Mark's
>SameValue test.
>
>>-----Original Message-----
>>From: es-discuss-bounces at mozilla.org [mailto:es-discuss-
>>bounces at mozilla.org] On Behalf Of Igor Bukanov
>>Sent: Thursday, November 13, 2008 9:18 AM
>>To: Waldemar Horwat
>>Cc: Mark S. Miller; es-discuss
>>Subject: Re: === again (sorry)
>>
>>2008/11/11 Waldemar Horwat <waldemar at google.com>:
>>> Mark S. Miller wrote:
>>>>
>>>> The indexOf and lastIndexOf methods are new in ES3.1, and are the
>>only
>>>> methods in the entire spec that depend on ===.
>>>
>>> Strictly speaking that's true, but only because the switch statement
>>is not
>>> a method.  switch statements depend on ===.
>>
>>There was a recently reported bug for SpiderMonkey where the
>>implementation treated -0 as not equal to 0 for some optimized switch
>>cases. Given that the bug was present in the code at least since 1998
>>this gives indications that even for a switch a change to use
>>Object.identical, not ===, could be compatible with the web.
>>
>>Regards, Igor
>>_______________________________________________
>>Es-discuss mailing list
>>Es-discuss at mozilla.org
>>https://mail.mozilla.org/listinfo/es-discuss
>
>_______________________________________________
>Es-discuss mailing list
>Es-discuss at mozilla.org
>https://mail.mozilla.org/listinfo/es-discuss



More information about the Es-discuss mailing list