No subject


Sun Jul 4 11:13:42 PDT 2010


an inference from [[Class]]; if [[Class]] is x then [action]. However,<br>
from a programmer's perspective, `Object.prototype.toString.call(x)`<br>
cannot discriminate between objects originating in the host<br>
environment (what is currently defined as &quot;host object&quot;) and nati=
ve<br>
objects. Mostly they shouldn't care, but should follow the<br>
specification approach to derive [[Class]] based inference, however<br>
they can't follow that because that is not compatible with existing<br>
implementations (notably IE versions and Opera (which copied IE)), and<br>
making an &quot;isStrict&quot; supported global flag is not going to provid=
e a<br>
closely related inference about various types of host objects across a<br>
wide range of implementations in the wild.<br>
<br>
Internet Explorer 9 host objects seem to be absent of problems seen in<br>
previous versions of IE but there are still host objects that are<br>
callable, have [[Class]] &quot;Object&quot;, and are not implemented with n=
ative<br>
semantics. Two examples of such object are alert and addEventListener.<o:p>=
</o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Because that allows `alert` to be any native ECMAScript object<br>
&gt;&gt; (Function, Object, etc), while still letting it be defined as a ho=
st<br>
&gt;&gt; object and not violating that spec.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; &quot;that spec&quot;? What specification demands that alert be a host=
 object? I have<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">I cited 4.3.8; the definition of host object.<o:p></=
o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&gt; not heard of any. This might be a consequence of the upcoming WebIDL-t=
o-ES5<br>
&gt; language bindings, but I have seen no draft and so have no idea. My ow=
n<br>
&gt; preference would be for these language bindings to result in alert bei=
ng a<br>
&gt; native Function, but that's an argument for a different standards comm=
ittee<br>
&gt; ;).<br>
&gt;<br>
&gt; If an implementation's alert is a Function, then it is a native object=
 and<br>
&gt; its [[Class]] must be &quot;Function&quot;. It can still be an object =
provided by a<br>
&gt; host environment whose [[Call]] behavior is written in C&#43;&#43;. Th=
is simply<br>
&gt; makes it a host provided native built-in object (4.3.7), not a host ob=
ject.<br>
&gt;<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">No, alert is not a defined by ECMAScript specificati=
on. It is<br>
therefore host object, by definition of &quot;host object&quot; in ES5, s 4=
.3.8.<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;&gt; Iff, however, following my<br>
&gt;&gt; proposed amendment, `alert` had [[Class]] &quot;Object&quot;, and =
it was not a<br>
&gt;&gt; native ES object (as in IE versions), then it would be a specifica=
tion<br>
&gt;&gt; violation.<br>
&gt;&gt;<br>
&gt;&gt; &gt; But it is also used from JS. Host objects are exempt from mos=
t of the<br>
&gt;&gt; &gt; specific behaviors specified for specific kinds of native obj=
ects. Were<br>
&gt;&gt; &gt; a<br>
&gt;&gt; &gt; host object to be able to allege to be a kind of native objec=
t without<br>
&gt;&gt; &gt; behaving as that kind of native object behaves, that would be=
 bad.<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; This is not in the spec:<br>
&gt;&gt; &quot;without behaving as that kind of native object behaves&quot;=
<br>
&gt;&gt;<br>
&gt;<br>
&gt; See 4.3.6.<br>
&gt;<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">That is where native object is defined.<o:p></o:p></=
p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; While the specification does not preclude the possibility that a h=
ost<br>
&gt;&gt; object may be implemented with native semantics, it nonetheless<br=
>
&gt;&gt; defines a host object:<br>
&gt;&gt;<br>
&gt;&gt; | 4.3.8<br>
&gt;&gt; | &nbsp;host object<br>
&gt;&gt; | &nbsp;object supplied by the host environment to complete the<br=
>
&gt;&gt; | &nbsp;execution environment of ECMAScript.<br>
&gt;&gt; |<br>
&gt;&gt; | &nbsp;NOTE Any object that is not native is a host object.<br>
&gt;&gt;<br>
&gt;&gt; And that means that `alert`, `window`, `document`, XMLHttpRequest,=
 are<br>
&gt;&gt; all host objects. Whether or not those objects are implemented as<=
br>
&gt;&gt; native ECMAScript objects is another matter altogether.<br>
&gt;&gt;<br>
&gt;<br>
&gt; This is the crux. The language there is indeed poorly phrased. But nat=
ive<br>
&gt; objects are not host objects.<br>
&gt;<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">Where is that stated anywhere in the specification?<=
o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&gt; Indeed, it is so poorly phrased that perhaps we should add an errata t=
o<br>
&gt; clean this up. Sigh. cc'ing es5-discuss.<br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; It seems the the spec is wrong and that you have misinterpreted it=
. I<br>
&gt;&gt; believe that instead it should be written:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; Text missing?<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">Yes, as I wrote before:<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
| &nbsp;The value of the [[Class]] internal property of any non-native host=
<br>
| &nbsp;object must be any String value except one of..<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">The other possibility is that you have misinterprete=
d the definition<br>
of host object to mean something along the lines of &quot;any object that<b=
r>
is not a native object&quot;.<br>
<br>
And going by that, referring to the example, `alert` could be a native<br>
object and would then not be a host object.<br>
<br>
[...]<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&gt;&gt; &gt; (alert instanceof Function) is not a reliable test in either =
direction.<br>
&gt;&gt;<br>
&gt;&gt; No of course not.<br>
&gt;&gt;<br>
&gt;&gt; A<br>
&gt;&gt; &gt; host object as well as a native non-function is perfectly fre=
e to<br>
&gt;&gt; &gt; inherit<br>
&gt;&gt; &gt; from Function.prototype and thus pass this test. And an actua=
l function<br>
&gt;&gt; may<br>
&gt;&gt; &gt; be an instance of Function constructor from another frame and=
 so fail<br>
&gt;&gt; &gt; the<br>
&gt;&gt; &gt; test. But yes, iff alert is indeed a native function, it's [[=
Class]]<br>
&gt;&gt; should<br>
&gt;&gt; &gt; be &quot;Function&quot;.<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; Therein lies a contradiction: A host object here may be a function=
.<br>
&gt;&gt;<br>
&gt;<br>
&gt; No it may not. A host object may be callable and it may inherit from<b=
r>
&gt; Function.prototype, but it may not be a function.<br>
&gt;<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">Once again, ES5 does not preclude the possibility th=
at a host object<br>
may be implemented with native semantics.<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&gt;<br>
&gt;&gt; Yet because it is a host object, that same object's [[Class]] must=
 not<br>
&gt;&gt; be &quot;Function&quot;, and yet again, since it is a function, an=
d any function<br>
&gt;&gt; must have [[Class]] &quot;Function&quot;, then this object's [[Cla=
ss]] must be<br>
&gt;&gt; &quot;Function&quot;.<br>
&gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; However according to ES5 specs, any host object must not =
be withing<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; the set of values that are not allowable and so the assertion=
 could be<br>
&gt;&gt; &gt;&gt; made that if any object has a [[Class]] that is one of th=
ose values,<br>
&gt;&gt; &gt;&gt; then the object is not a host object.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Yes, that is intentional.<br>
&gt;&gt;<br>
&gt;&gt; Then it will fail today, as<br>
&gt;&gt;<br>
&gt;&gt; javascript: alert(({}).toString.call(alert))<br>
&gt;&gt;<br>
&gt;&gt; - will result &quot;[object Object]&quot; or &quot;[object Functio=
n]&quot;<br>
&gt;&gt;<br>
&gt;<br>
&gt; 1) No current implementations claim ES5 conformance.<br>
&gt; 2) On ES5 conformant implementations, alert may well be a function in =
which<br>
&gt; case the second result will remain correct.<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">The only way that could be anything other than a con=
tradiction is if<br>
you have redefined &quot;host object&quot; to be as I suggested above (I'll=
<br>
repeat that one more time).<br>
<br>
`alert` is a host object by definition of host object in s. 4.3.8. It<br>
seems as if you have misinterpreted that definition as: &quot;any object<br=
>
that is not a native object&quot;. Is that how you read it?<br>
<br>
That is a significantly different definition than either definition in<br>
Eds 3 or 5.<br>
<br>
Ed 3:<br>
<br>
| &nbsp; A host object is any object supplied by the host<o:p></o:p></p>
<div>
<p class=3D"MsoNormal">| &nbsp;environment to complete the execution enviro=
nment of<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">| &nbsp;ECMAScript. Any object that is not native is=
 a host object.<br>
<br>
Ed 5:<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">| &nbsp;object suppli=
ed by the host environment to complete<br>
| &nbsp;the execution environment of ECMAScript.<br>
|<br>
| &nbsp;NOTE Any object that is not native is a host object.<o:p></o:p></p>
</div>
<p class=3D"MsoNormal">Perhaps this is a case of denying the antecedent?<br=
>
1. if (not native) then host object.<br>
2. alert is native,<br>
therefore, alert is not host object. (false conclusion)<br>
<br>
&lt;<a href=3D"http://en.wikipedia.org/wiki/Denying_the_antecedent" target=
=3D"_blank">http://en.wikipedia.org/wiki/Denying_the_antecedent</a>&gt;<br>
<br>
If the definition of host object is correct then the clause that<br>
mentions &quot;[[Class]]&quot; property must change as I initially suggeste=
d.<br>
However, if what appears to be your definition of host object was also<br>
what was intended by the editor, then that definition should be<br>
rewritten instead.<br>
<br>
If a host object is defined as being any object supplied by the host<br>
environment that is not a native object, then the spec should state<br>
so. If, however, a host object may be a native object -- and that is<br>
how it is currently defined, then for any host object that is not a<br>
native object, that object's [[Class]] property must not be in the set<br>
of class values for native types.<br>
<span style=3D"color:#888888"><br>
Garrett</span><o:p></o:p></p>
</div>
<p class=3D"MsoNormal"><br>
<br clear=3D"all">
<br>
-- <br>
&nbsp; &nbsp; Cheers,<br>
&nbsp; &nbsp; --MarkM<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>

--_000_90EDC335A511F2479C63F7337D3CE7DB511742DATK5EX14MBXC116r_--


More information about the es5-discuss mailing list