need some clarification on compile-time type vs. run-time type

Brendan Eich brendan at
Mon Nov 12 16:15:45 PST 2007

On Nov 12, 2007, at 3:58 PM, Brendan Eich wrote:

>> There are couple potential problems with upgrading |instanceof| to
>> match the syntax of the revised |is|:
>> 1) Function expr syntax ambiguity. Consider:
>> a) x is function(p: int): int // ok
>> b) x is function(p: int): int {} // syntax error
>> c) x instanceof function(p: int): int // ok?
>> d) x instanceof function(p: int): int {} // syntax error?
> Oh, I see -- on second thought I meant nothing like allowing (d) --

Er, I meant (c), if you remove type annotations from the function  
param and result. In ES3 today, you can write

js> ({}) instanceof function (){}

It's silly, of course, because the function expression is captured by  
the right operand and could not have been constructed via operator  
new to get the left operand. But it's valid ES3 syntax, so we can't  
switch instanceof's right operand to favor a function structural type.


More information about the Es4-discuss mailing list