Jan 31 TC39 Meeting Notes

Joshua Bell jsbell at chromium.org
Thu Feb 7 09:41:38 PST 2013


Re: Maps and Sets comparators:

On Thu, Feb 7, 2013 at 8:27 AM, Rick Waldron <waldron.rick at gmail.com> wrote:

> # January 30 2013 Meeting Notes
>
> (snip)


> ARB: if we have a forth form of equality as "default", we should be
> honest, name it, and make it available separately
>
> YK: Can we use "===" and disallow NaN as a key?
>
> WH: No.
>
> AWB: Why not?
>
> Comparison of the "===" vs Object.is case, w/r to NaN, +0/-0
>
> MM: Move `Object.is` to `Math.is`?
>
> WH: No, it accepts non-numbers
>
> WH: The longer we debate this, the more I want to just go with current
> implementations [that don't have a comparator parameter and always do the
> "is" semantics].
>
> RW: +1
>
> AWB: We should use this unnamed function as default, "default" is a fine
> name for it. If there is a demand, we can add it in the future.
>
> EA: We can skip the name...
>
> ARB: You might have circumstances where you do your comparison outside of
> the map.
>
> MM: General comparator argument, are we happy with this considering a
> hypothetical future that allows arbitrary equivalence class?
>
> WH: As long as it's an equivalence class, if you allow anything else, you
> run into trouble.
>
>
> **Conclusion/Resolution**
> - `Map( iterator = undefined, comparator = undefined )`
> - `Set( iterator = undefined, comparator = undefined )`
>
> - If the second argument is "is", use "Object.is"
> - Otherwise, use "==="
>
> ```js
> Map.defaultComparator( a, b )
> Set.defaultComparator( a, b )
> ```
>

Is that "Otherwise" clause correct, or should it be: "Otherwise, use
Map/Set.defaultComparator"

...where (based on the preceding text) the defaultComparator is like ===
w/r/t +/-0 but NaN's are equated?

i.e. Map.defaultComparator = function(a, b) {
  return ((a !== a) && (b !== b)) || (a === b);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130207/8e61ebb5/attachment-0001.html>


More information about the es-discuss mailing list