Re: Simple maps/sets: parameterize the comparator?

2012-01-02 Thread Andreas Rossberg
On 29 December 2011 18:48, Allen Wirfs-Brock al...@wirfs-brock.com wrote: The existence of WeakMap/Map implies the existence of an internal object identify hash value. Why? AFAICT, there is nothing currently requiring these collections to be implemented as hash tables in particular. And there

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Axel Rauschmayer
We should probably avoid pressures for the build-ins to cover all possible use cases. In ES.next we will should have all the primitives necessary for JS programmers to define their own efficient collection objects, including various kinds of hash-tables. Hopefully some good libraries of

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Allen Wirfs-Brock
On Dec 29, 2011, at 6:34 AM, Axel Rauschmayer wrote: We should probably avoid pressures for the build-ins to cover all possible use cases. In ES.next we will should have all the primitives necessary for JS programmers to define their own efficient collection objects, including various

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Allen Wirfs-Brock
On Dec 28, 2011, at 10:14 PM, Mark S. Miller wrote: On Wed, Dec 28, 2011 at 10:06 PM, Brendan Eich bren...@mozilla.com wrote: From: Mark S. Miller erig...@google.com I take it you are simply reiterating the desire for a standard system provided high entropy object-identity hash that is

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Allen Wirfs-Brock
On Dec 28, 2011, at 6:48 PM, Mark S. Miller wrote: ... Likewise, I expect that detecting misbehavior sort comparison functions is too hard to be practical. However, I strongly disagree that the current underspecification isn't a problem. How undefined is this behavior? (Actually, the

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread David Bruant
Le 29/12/2011 05:08, Mark S. Miller a écrit : On Wed, Dec 28, 2011 at 6:48 PM, Mark S. Miller erig...@google.com mailto:erig...@google.com wrote: [...] For example, regarding sorting, leaving aside sparseness, I suspect our shared model is that any sort algorithm implementation

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Axel Rauschmayer
I’m not sure that there is much one can do to protect programmers from themselves, given that writing good hash functions is hard. One could provide a test suite. Random thoughts: - Enforce that both equality and hash function are specified. A common Java problem. - Provide a hash function

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Mark S. Miller
On Thu, Dec 29, 2011 at 9:48 AM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: [...] For example, regarding sorting, leaving aside sparseness, I suspect our shared model is that any sort algorithm implementation itself takes only the following observable steps, but in some arbitrary order and

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Axel Rauschmayer
I’m curious: Is it likely that such libraries will get written by the community? This domain does not seem to enjoy much interest. (I would volunteer, but have neither the necessary expertise/experience nor the time.) Well, If nobody else creates such a library, I will. + Number.MAX_VALUE

Re: Simple maps/sets: parameterize the comparator?

2011-12-28 Thread Allen Wirfs-Brock
On Dec 27, 2011, at 10:20 AM, Mark S. Miller wrote: 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

Re: Simple maps/sets: parameterize the comparator?

2011-12-28 Thread Mark S. Miller
On Wed, Dec 28, 2011 at 4:23 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: On Dec 27, 2011, at 10:20 AM, Mark S. Miller wrote: 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

Re: Simple maps/sets: parameterize the comparator?

2011-12-28 Thread Mark S. Miller
On Wed, Dec 28, 2011 at 10:06 PM, Brendan Eich bren...@mozilla.com wrote: From: Mark S. Miller erig...@google.com I take it you are simply reiterating the desire for a standard system provided high entropy object-identity hash that is guaranteed to correspond to === and is. I agree (though

Simple maps/sets: parameterize the comparator?

2011-12-27 Thread Axel Rauschmayer
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 a...@rauschma.de home: rauschma.de twitter: