Type Checking?

Brendan Eich brendan at mozilla.org
Thu Oct 11 21:19:10 PDT 2007

On Oct 11, 2007, at 8:02 PM, Garrett Smith wrote:

>> If you want to apply or call a non-function
>> callable, use Function.apply(callable, thisp, argArray) or
>> Function.call(callable, thisp, arg1, ...argN).
> So these are equivalent?
> aNonFunctionCallableObj()
> Function.call( aNonFunctionCallableObj )

We don't need to go back and forth -- I wrote essentially the same  
thing, but included the optional arguments. The two expressions you  
wrote are equivalent assuming the global object should bind to |this|  
for both to be equivalent.

> If an object is invokable with arguments  (), but not a Callable, it's
> impossible to type check.  IE's call-like operation on with () is not
> [[call]].

Why do you say that? There's no reflection of [[Call]] into the  
language yet, so how can you tell?

(Don't rely on typeof x == "function" meaning x.[[Call]] exists --  
browsers do not follow ES3 here, although we tried in SpiderMonkey  
for years before throwing in the towel.)

> Microsoft often says that it is necessary to retain backwards
> compatibility. I would hope they would

You're barking up the wrong tree here. This is es4-discuss.

> Mozilla has this weird function-like thing, too, (only with
> document.all, which is not used much anymore)

As I keep saying, any reflection of document.all in an ES4 "DOM level  
0 plus IE quirks" binding should indeed make (document.all is  
Callable) => true.

>> I don't know what "BackCompat mode" means, but we do reflect
>> document.all if a script uses it without object-detecting it, and
>> only in such cases (since many well-written scripts fork based on if
>> (document.all) ... else ... tests and we want to run the else  
>> clause).
> document.compatMode
> "CSS1Compat"  -- standards mode
> "BackCompat" - quirks mode
> BackCompat supports document.all

No, you're mixing things up. As I wrote, our document.all emulation  
has nothing to do with DOM specs or document.compatMode, and it works  
irrespective of the latter's value.

> Mozilla really made document.all look like IE's weird
> collection-that-can-be-invoked-with-().

Like, yeah -- that was the point!


More information about the Es4-discuss mailing list