Simple maps/sets: parameterize the comparator?

Mark S. Miller erights at google.com
Tue Dec 27 10:20:49 PST 2011


Hi Axel, yes, I would like to extend their constructor in this way.
However, I'm not sure how to spec it -- help appreciated. The problem is
that the comparator needs to provide both an equivalence operation and a
corresponding hash operation. When these agree, all is well. What should we
specify happens when passing in a misbehaving comparator? The dilemma is
that
1) detecting misbehavior is expensive,
2) having a deterministic collection misbehavior in the face of comparator
misbehavior seems hard, and
3) we'd like to avoid yet more under-specification. The similar
under-specification of Array.prototype.sort is already bad enough.


On Tue, Dec 27, 2011 at 7:22 AM, Axel Rauschmayer <axel at rauschma.de> wrote:

> http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets
>
> Currently, using Object.is() is hard-coded. But one could allow a
> comparator function being handed in (with Object.is being the default).
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111227/62d1ed0b/attachment.html>


More information about the es-discuss mailing list