On Fri, May 24, 2013 at 10:11 AM, Andreas Rossberg <[email protected]> wrote:
> On 24 May 2013 18:55, Tab Atkins Jr. <[email protected]> wrote:
>> I simply don't understand why Javascript's Map apparently makes this
>> impossible, forcing all Maps to be any->any, and offering only hacks
>> (admittedly clever ones) that partially work if you want a restricted
>> type.
>
> I haven't really followed this thread, but could it be that you are
> confusing polymorphic instantiation with subtyping here? A Map(String,
> String) is an instance of a polymorphic Map(A, B), but it is not a
> subtype of Map(Any, Any), because a map is contravariant in its key
> type. That's why the subclassing you have in mind does not really make
> sense from a subtyping perspective. If you want to restrict it, then
> you'd have to do so by wrapping, not by inheritance.

This is a reasonable argument, but there's no other way to express the
right semantics in JS (this is a map, operations you add to general
maps apply to this as well) without subtyping.  If we ever come up
with better solutions to handling OO, great, but I'm unhappy if we
block any attempt to address Web API map-like needs just because it's
not *technically* a subclass.

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to