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

On Mon, Mar 9, 2015 at 11:23 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> (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.)

ES doesn't really have the concept of "interface" which really is what
we're looking for here. It always ties interface and implementation
together into specific classes. Classes which always have a
constructor and which makes sense on their own.

Another example of when this problem shows up is in the design of the
Stream class. The two "ends" of a stream should really be two separate
objects with a specified interface. Those two objects should always
work in concert to make up the stream object. However JS doesn't allow
creation of those two objects without requiring that each object also
can be instantiated and useful on its own.

The closest thing to "interface" that JS has is "duck type".

/ Jonas

Received on Monday, 9 March 2015 19:06:17 UTC