Strawman proposal: new `is` operator

Isiah Meadows impinball at gmail.com
Tue Aug 26 06:00:24 PDT 2014


I stand corrected on the creation aspect.

Isiah Meadows
On Aug 25, 2014 9:56 PM, "Brendan Eich" <brendan at mozilla.org> wrote:

> Isiah Meadows wrote:
>
>>
>> Cc the list...
>>
>> On Aug 25, 2014 6:06 PM, "Isiah Meadows" <impinball at gmail.com <mailto:
>> impinball at gmail.com>> wrote:
>>
>>     There really shouldn't be any sort of object construction needed
>>     to check types like this. `isa` may be better, anyways, but I
>>     still find that requirement to build and destroy an object to
>>     check somewhat counterproductive.
>>
>>
> What object is built and destroyed?
>
> Note that for primitive types no wrapper need be created just to call a
> method, in general for JIT-optimized code, and definitely for strict mode
> code.
>
>      Andrea gets what I'm talking about. Also, another (possibly
>>     separate) proposal would be to make cases like `"foo" instanceof
>>     String" === true` instead of their current behavior, throwing a
>>     TypeError. (I believe...I'm on a phone, not a PC where I can test.
>>     Correct me if I'm wrong.)
>>
>>
> (Your phone doesn't have a browser with a console? :-P)
>
> js> "hi" instanceof String
> false
> js> 42 instanceof Number
> false
> js> false instanceof Boolean
> false
>
> These are well-defined for instanceof, without throwing. Changing results
> to true would be backward incompatible.
>
> 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.
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140826/00510e5a/attachment.html>


More information about the es-discuss mailing list