Can DOM methods be native Function objects?

Mark S. Miller erights at google.com
Sun Oct 10 22:02:37 PDT 2010


It is really a terrible shame this is all so confusing. Part of the problem
is terminology wrongly suggesting other meanings. "host" simply means
"non-native".

The ES5 spec defines a set of internal nominal types-as-contracts,
identified by their [[Class]] binding. Whether built-in or not, an object
claiming one of these [[Class]]es must obey the corresponding contract. For
the specific specified contracts, these objects are "native" objects. The
spec allows an implementation to provide "host" objects that don't claim to
satisfy one of these more specific contracts by having a different
[[Class]]. Such objects may still happen to satisfy one of these more
specific contracts, but they do not claim to. All objects, host or native,
must still satisfy the general contract that applies to all ES objects.

As for whether DOM methods that could, within their specification, claim to
be native Functions, ES doesn't say whether they should or should not claim
to be functions. It only says that if they do claim to be functions they
must actually be functions.

Language lawyering aside, my own sense is that all methods that could be
functions should be functions. We should only specify that an object is
non-native when we need to.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20101011/5fed549a/attachment.html>


More information about the es-discuss mailing list