On Jun 14, 2012, at 3:25 PM, Mark S. Miller wrote:
> On Thu, Jun 14, 2012 at 7:59 PM, Andrea Giammarchi
> <[email protected]> wrote:
>> This is basically what I am doing except I find Array#indexOf as it is
>> pointless ... or better, something that should be fixed in the next version
>> of ECMAScript.
>
> I agree. I argued that it should be fixed as of ES5, but lost the
> argument on compatibility grounds. No one had measurements either way,
> so in the absence of evidence we properly made the conservative
> choice. The other place where this occurs, and IMO is an even worse
> problem is switch:
>
> function sw(x) {
> switch (x) {
> case NaN: return 'match';
> default: return 'default';
> }
> }
> sw(NaN); // returns: 'default'
>
>
> It's too late for ES6. In order to fix these for ES7, someone would
> need to gather evidence that the web corpus does not depend on the
> current broken behavior.
I disagree about the too lateness. Specification-wise this would be a minor
change and the absolute cut-off date is about a year away. If we actually had
evidence that it was a safe breaking change we could do it. Of course, getting
that evidence is not a trivial matter.
Regarding switch statements. We could make
case NaN:
be an early error. It wouldn't take care of computed NaN case expression
values but it would take care of the obviously buggy literal cases like your
example.
We would probably still need some evidence that an early error on case NaN
wouldn't be disruptive.
Allen
>
> --
> Cheers,
> --MarkM
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss