On Nov 2, 2012, at 11:55 AM, Mark S. Miller <erig...@google.com> wrote:

> The only consistency issue is: should array.has agree with sense and all 
> other collections, or should it agree with array.indexOf / lastIndexOf. FWIW, 
> I would prefer not to add any more conveniences that further entrench 
> unexpected === checks.
> 
> 
>     [NaN].has(NaN) // false
> 
> makes little sense.
> 
>     [0.0].has(-0.0) // true
> 
> makes somewhat more sense, but not enough. Please let's either use add "has" 
> using SameValue or not add anything at all.

Sorry to complicate the opinion landscape further, but I'm not convinced that 
any collections should be using SameValue. Looking over my personal notes from 
an earlier conversation Mark and I had about maps and sets, I think we came to 
something where the default equivalence should be the tightest possible one 
(SameValue), but it should be possible to provide your own equality predicate 
as an optional constructor argument. We don't have that option for arrays.

There are plenty of operations that can result in a -0 without the programmer 
being aware, such as Math functions. I shudder to imagine debugging a program 
like this:

    [Math.round(-0.1)].has(0) // false!

I agree that NaN should be equated, but I'm pretty nervous about the idea of 
distinguishing 0 and -0, especially when there's no way to override that 
behavior.

Dave

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to