On Tue, Aug 26, 2014 at 3:56 AM, Brendan Eich <bren...@mozilla.org> wrote: > > ES4 had 'is' as a type-classifying operator: > > http://wiki.ecmascript.org/doku.php?id=proposals:is_as_to > http://wiki.ecmascript.org/doku.php?id=discussion:is_as_to > > It would be a mistake to define 'is' without defining the (unsound) type > system it depends on. This is a challenge, but TypeScript and other > close-to-ES6 languages have sallied forth. We need a detailed proposal. >
Though TypeScript cannot support an `is` operator because it only has duck typing/structural types. Which makes sense for the web, I think, given that lots of code has to interact across realms, and staticly-checked types with their inherent anti-modularity are a problem for that. AS3 (which implements ES4's `is` operator) has the same issue across Flash's ApplicationDomains. Note that ES6's formulation of `instanceof` in terms of an optional `@@hasInstance` trap can, in combination with the cross-realm symbol registry, probably be used to implement the desired behavior, even across realms. For non-primitives, at least.
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss