Backstory/rationale for disallowing -0 in Map keys and Sets?

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Oct 10 18:03:33 UTC 2018



> On Oct 10, 2018, at 3:42 AM, T.J. Crowder <tj.crowder at farsightsoftware.com> wrote:
> 
> the ambiguity that -0 and +0 are often hard to distinguish (Number's `toString` returns `"0"` for both, for instance; operations involving them largely don't care about the pseudo-sign of 0). Is that the rationale? Basically, avoid a footgun while ensuring consistency?

Yes, exactly.

Also, at that time the proposed comparator parameter was already restricted to selecting between SameValue and SameValue0 because of concerns/open issues about an unrestricted comparator parameter.  After it was demonstrated that a subclass that distinguished ±0 was fairly trivial to write the comparator parameter was eliminated.

The assumption was that someday an extension proposal to add a generalized comparator parameter would be brought forward and considered.

Allen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20181010/108bbca8/attachment.html>


More information about the es-discuss mailing list