Re: Web IDL maplike: Allow spec prose to specify how key-type should be compared?

On Mon, Mar 2, 2015 at 4:45 PM, Mark S. Miller <erights@google.com> wrote:
> On Mon, Mar 2, 2015 at 3:08 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> On Mon, Mar 2, 2015 at 2:28 PM, David Dorwin <ddorwin@google.com> wrote:
>
> [...]
>>
>> Given that this is backed by a Map, I don't think we can realistically
>> do this until Maps gain the ability to specify a key comparator.
>
> The following code is untested, and was written only to play with an idea
> provoked by this thread. It may also be besides the actual point of this
> thread, but...
[snip code]

Yeah, it's not that difficult to design an object that exposes the Map
interface and does key-comparing for you, but the important bit is
that *that's not a Map*.  Future extensions to Map, or user-extensions
to the object, don't apply to it, Map.prototype.set doesn't work on
it, etc.

(This is one more instance of the general problem I've brought up a
few times, that Map/Set aren't customizable in any way and it's really
an issue.  There should be an internal "SimpleMap" that just exposes
the core methods needed, and which can be swapped out by users or
specs for another object undetectably, so that Map/Set operate as an
interface contract.)

~TJ

Received on Monday, 9 March 2015 18:24:04 UTC