W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2015

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 9 Mar 2015 11:23:17 -0700
Message-ID: <CAAWBYDCqdkrw5mT9xVo+be8AtbmOnzHYshf=2AQSP7WxmFzGFw@mail.gmail.com>
To: "Mark S. Miller" <erights@google.com>
Cc: David Dorwin <ddorwin@google.com>, public-script-coord <public-script-coord@w3.org>, Boris Zbarsky <bzbarsky@mit.edu>
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

This archive was generated by hypermail 2.3.1 : Monday, 9 March 2015 18:24:06 UTC