Can DOM methods be native Function objects?
brendan at mozilla.com
Sun Oct 10 21:27:04 PDT 2010
On Oct 10, 2010, at 8:54 PM, Garrett Smith wrote:
> On 10/10/10, Brendan Eich <brendan at mozilla.com> wrote:
>> On Oct 10, 2010, at 4:14 PM, Mark S. Miller wrote:
>>> My interpretation is that the spec in this regard is consistent with
>>> reality as intended and is not an ass.
> (Somewhat disconcerting to hear hints of the spec being called an ass.)
Lighten up! First, I wrote "If" in "If the spec says otherwise, the spec is an ass, to borrow from Dickens." Second, the Dickens in question is Oliver Twist, see http://www.texasbar.com/saywhat/weblog/buchmeyer_article_archive/may84.asp. Too much "judicial reasoning" about specs trumping more humorous reality (the ES standard is Mr. Bumble, the DOM standard is his wife; wait, no... :-P).
> If a host method obeys that contract, how could one determine if it
> were not a native function?
Some people read the spec to define any such method as a host (callable) object of some kind, never a native function.
> Some implementations have callable host objects that don't need to be
> functions, e.g. document.images, which in many implementations is
> callable as "document.images(0)" but is not a function.
(A VBScript-ism, not being standardized in WebIDL.)
> Although the spec draws a bright
>>> line around its built-ins vs. "host objects", real implementations use the
>>> same native-function variant of function objects for both. This is
>>> important reality to support with some spec fixes.
> Any DOM host object specified to be a native ES object can be expected
> to follow native semantics. What are you hoping to fix?
The belief that keeps recurring on this list, most recently in Cameron's post, that the specs forbid DOM methods from being native function objects. Cameron's second bulleted "Which one of the following is true?" answer was
> * a custom [[Call]] is needed, but native objects are allowed to have
> a custom [[Call]]; or
is the right answer but it is not obvious from ES5 that this is allowed for "host objects" not defined by the spec. It's a subtle point that we should clarify so we don't have to around this block again.
More information about the es-discuss