Tab Atkins Jr. wrote:
If we did this, the only reason to continue subclassing Map is to get
instanceof checks to work. Is this acceptable?
I think it's either irrelevant (no one tests 'aUrlQuery instanceof Map')
or else a potential problem (cross-frame instanceof).
Are there better
ways, perhaps on the horizon? Any other thoughts?
Testing whether something quacks like a duck has not been on the agenda
since ES4's like, which had other issues (as an annotation, arguably not
so much as an operator). Just testing for properties, even testing their
values against certain "types", is perhaps not enough to deduce Map-ness
or (in the case of urlQuery) string->string Map-ness.
We can let people develop protocols, functional predicate APIs, for
this. Or we could try to preload some as built-ins. I fear any committee
shooting once, hitting some target somewhere, and pushing that into the
spec.
Where I would like to go, if you force me to pick a promising path:
http://disnetdev.com/contracts.coffee/#duck
http://disnetdev.com/blog/2011/09/05/Duck-Typing-Invariants-In-contracts.coffee/
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss