Can DOM methods be native Function objects?

Mark S. Miller erights at google.com
Sun Oct 10 22:24:29 PDT 2010


On Mon, Oct 11, 2010 at 5:54 AM, Garrett Smith <dhtmlkitchen at gmail.com>wrote:

> >> In other words, [[Class]] "Function" is one of the native internal
> nominal
> >> types whose contract is defined by the spec. If a method of a host
> object
> >> obeys that contract, it would be best for it to actually be a native
> >> function.
> >>
>
> If a host method obeys that contract, how could one determine if it
> were not a native function?
>

If the "one" in your question is the JS programmer, one determines by
testing if its [[Class]] is "Function".



>
> I think maybe if you want to say that host methods should be just
> specified as functions, where that makes sense.


Need to be careful with terms to avoid confusion here. We're talking about
methods of host objects. If we're already talking about a host method, then
the matter is decided. If it is a host method, then presumably it is a host
object, and so it is by definition not a function.

Substituting "method of host object" above, I agree. But as a normative
issue, this currently falls in the gap between w3c and ecma.




> Because then you know
> you have a function, and thus a "length" property, [[Call]] property,
> etc.
>

y



>
> And that brings me to my next point: AIUI, host objects have two
> types. We discussed this before...
> (searching archives...)
>
> | The specification allows for two types of host objects:
> |  * host objects as native objects
> |  * host objects as not native objects (does not use
> | native semantics)
>

Link please? IIRC, this part of the conversation was subsequently falsified.
"host" and "native" are disjoint. "host" simply means not "native". The
first bullet above makes no sense.




>
> and
>
> |  While the specification does not preclude the possibility that a host
> |  object may be implemented with native semantics, it nonetheless
> |  defines a host object:
>
> From thread "[[Class]] Property of Host Object".
>
> 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?
>

Agree with the thought, but again let's keep our terminology straight. If a
DOM object is specified to be a native object, then it is a DOM native
object, not a DOM host object.



> --
> Garrett
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20101011/2bba57f3/attachment-0001.html>


More information about the es-discuss mailing list