On 8/12/14, Allen Wirfs-Brock <[email protected]> wrote:
>
Allen -
> On Aug 12, 2014, at 9:44 AM, Garrett Smith wrote:
>
>> What's the explanation and reason for this strange characteristic of
>> the OBJECT element in Firefox?
>>
>> Firefox 31:
>> typeof document.createElement("object")
>> "function"
>> Function.prototype.toString.call(document.createElement("object"));
>> TypeError: Function.prototype.toString called on incompatible object
>>
>> If the typeof OBJECT results "function" then it either:
>> a) implements [[Call]] or
>> b) is exotic
>>
>> Since calling `Function.prototype.toString` with OBJECT as the this
>> value results in a TypeError, it appears that the OBJECT does not
>> implement [[Call]] and thus the only explanation is that the OBJECT is
>> exotic. Did I get that right? Or is there another explanation?
>>
I based this conclusion off of the latest ES6 draft, at:
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-function.prototype.tostring
"throws a TypeError exception if its this value does not have a
[[Call]] internal method"
>> What's the explanation and reason for this strange characteristic of
>> the OBJECT element in Firefox?
>
> I don't see any where in your test where you [[Call]] OBJECT.
>
I tested the typeof operator to see if the OBJECT implements [[Call]]
by using typeof. The result was "function". Please go back and read
all replies.
> You [[Call]] Function.prototype.toString with OBJECT passed as the this
> value.
>
> The ES5 spec. clearly says that F.p.toString is called with a this value
> that is not a "Function object". Note this usage of "Function object"
> means an actual instance of the built-in Function constructor and not the
> more general, any object that isCallable.
>
ES5, in a few places, vascillates between the terms "function object"
and isCallable. E.g. "When the [[Call]] internal method for a Function
object..." yet there is no description of what happens when [[Call]]
is called on any object that implements [[Call]] but is not a function
(non-function host objects). Such objects not only exist but are
mentioned under the definition of the typeof operator:-
Object (implements [[Call]]) "function
There is also the failure of ES5 to differentiate between the two
types of host objects: native, and non-native, as I brought up and as
we discussed over 4 years ago. This differentiation is explained in
the ES6 draft as "exotic objects".
The ES6 replaces "function object" with "isCallable" and "implements
[[Call]]" in many places, and the place that is of concern here is the
description of Function.prototype.toString:
| Function.prototype.toString
| ...
|
| The toString function is not generic; it throws a
| TypeError exception if its this value does not have
| a [[Call]] internal method. Therefore, it cannot be
| transferred to other kinds of objects for use as a method.
Do you agree or disagree with the fact that the OBJECT implements
[[Call]]? And if you disagree, please explain.
Are you proposing that the definition of Function.prototype.toString
needs to be reverted to once again use "function object"? If not, what
is your proposal?
--
Garrett
@xkit
ChordCycles.com
garretts.github.io
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss