Strawman proposal: new `is` operator

Till Schneidereit till at tillschneidereit.net
Tue Aug 26 05:18:20 PDT 2014


On Tue, Aug 26, 2014 at 3:56 AM, Brendan Eich <brendan at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140826/5568d84e/attachment-0001.html>


More information about the es-discuss mailing list