No subject
Sun Jul 4 11:13:41 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 "host object") 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 "isStrict" 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]] "Object", 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"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
><br>
><br>
>><br>
>> Because that allows `alert` to be any native ECMAScript object<br>
>> (Function, Object, etc), while still letting it be defined as a ho=
st<br>
>> object and not violating that spec.<br>
><br>
><br>
><br>
> "that spec"? What specification demands that alert be a host=
object? I have<o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">I cited 4.3.8; the definition of host object.<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
> not heard of any. This might be a consequence of the upcoming WebIDL-t=
o-ES5<br>
> language bindings, but I have seen no draft and so have no idea. My ow=
n<br>
> preference would be for these language bindings to result in alert bei=
ng a<br>
> native Function, but that's an argument for a different standards comm=
ittee<br>
> ;).<br>
><br>
> If an implementation's alert is a Function, then it is a native object=
and<br>
> its [[Class]] must be "Function". It can still be an object =
provided by a<br>
> host environment whose [[Call]] behavior is written in C++. Th=
is simply<br>
> makes it a host provided native built-in object (4.3.7), not a host ob=
ject.<br>
><o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">No, alert is not a defined by ECMAScript specification. It is<br>
therefore host object, by definition of "host object" in ES5, s 4=
.3.8.<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
><br>
><br>
><br>
>> Iff, however, following my<br>
>> proposed amendment, `alert` had [[Class]] "Object", and =
it was not a<br>
>> native ES object (as in IE versions), then it would be a specifica=
tion<br>
>> violation.<br>
>><br>
>> > But it is also used from JS. Host objects are exempt from mos=
t of the<br>
>> > specific behaviors specified for specific kinds of native obj=
ects. Were<br>
>> > a<br>
>> > host object to be able to allege to be a kind of native objec=
t without<br>
>> > behaving as that kind of native object behaves, that would be=
bad.<br>
>> ><br>
>><br>
>> This is not in the spec:<br>
>> "without behaving as that kind of native object behaves"=
<br>
>><br>
><br>
> See 4.3.6.<br>
><o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">That is where native object is defined.<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
><br>
>><br>
>> While the specification does not preclude the possibility that a h=
ost<br>
>> object may be implemented with native semantics, it nonetheless<br=
>
>> defines a host object:<br>
>><br>
>> | 4.3.8<br>
>> | host object<br>
>> | object supplied by the host environment to complete the<br=
>
>> | execution environment of ECMAScript.<br>
>> |<br>
>> | NOTE Any object that is not native is a host object.<br>
>><br>
>> And that means that `alert`, `window`, `document`, XMLHttpRequest,=
are<br>
>> all host objects. Whether or not those objects are implemented as<=
br>
>> native ECMAScript objects is another matter altogether.<br>
>><br>
><br>
> This is the crux. The language there is indeed poorly phrased. But nat=
ive<br>
> objects are not host objects.<br>
><o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Where is that stated anywhere in the specification?<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
> Indeed, it is so poorly phrased that perhaps we should add an errata t=
o<br>
> clean this up. Sigh. cc'ing es5-discuss.<br>
><br>
><br>
>><br>
>> It seems the the spec is wrong and that you have misinterpreted it=
. I<br>
>> believe that instead it should be written:<br>
>><br>
>><br>
> Text missing?<o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Yes, as I wrote before:<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
| The value of the [[Class]] internal property of any non-native host=
<br>
| object must be any String value except one of..<o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">The other possibility is that you have misinterpreted the definiti=
on<br>
of host object to mean something along the lines of "any object that<b=
r>
is not a native object".<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"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
>> > (alert instanceof Function) is not a reliable test in either =
direction.<br>
>><br>
>> No of course not.<br>
>><br>
>> A<br>
>> > host object as well as a native non-function is perfectly fre=
e to<br>
>> > inherit<br>
>> > from Function.prototype and thus pass this test. And an actua=
l function<br>
>> may<br>
>> > be an instance of Function constructor from another frame and=
so fail<br>
>> > the<br>
>> > test. But yes, iff alert is indeed a native function, it's [[=
Class]]<br>
>> should<br>
>> > be "Function".<br>
>> ><br>
>><br>
>> Therein lies a contradiction: A host object here may be a function=
.<br>
>><br>
><br>
> No it may not. A host object may be callable and it may inherit from<b=
r>
> Function.prototype, but it may not be a function.<br>
><o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Once again, ES5 does not preclude the possibility that a host obje=
ct<br>
may be implemented with native semantics.<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p=
t"><br>
><br>
>> Yet because it is a host object, that same object's [[Class]] must=
not<br>
>> be "Function", and yet again, since it is a function, an=
d any function<br>
>> must have [[Class]] "Function", then this object's [[Cla=
ss]] must be<br>
>> "Function".<br>
>><br>
>> ><br>
>> ><br>
>> >><br>
>> >> However according to ES5 specs, any host object must not =
be withing<br>
>> ><br>
>> > the set of values that are not allowable and so the assertion=
could be<br>
>> >> made that if any object has a [[Class]] that is one of th=
ose values,<br>
>> >> then the object is not a host object.<br>
>> ><br>
>> ><br>
>> > Yes, that is intentional.<br>
>><br>
>> Then it will fail today, as<br>
>><br>
>> javascript: alert(({}).toString.call(alert))<br>
>><br>
>> - will result "[object Object]" or "[object Functio=
n]"<br>
>><br>
><br>
> 1) No current implementations claim ES5 conformance.<br>
> 2) On ES5 conformant implementations, alert may well be a function in =
which<br>
> case the second result will remain correct.<o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">The only way that could be anything other than a contradiction is =
if<br>
you have redefined "host object" 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: "any object<br=
>
that is not a native object". 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>
| A host object is any object supplied by the host<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">| environment to complete the execution environment of<o:p><=
/o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">| 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"mso-margin-top-alt:auto;margin-bottom:12.0p=
t">| object supplied by the host environment to complete<br>
| the execution environment of ECMAScript.<br>
|<br>
| NOTE Any object that is not native is a host object.<o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">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>
<<a href=3D"http://en.wikipedia.org/wiki/Denying_the_antecedent" target=
=3D"_blank">http://en.wikipedia.org/wiki/Denying_the_antecedent</a>><br>
<br>
If the definition of host object is correct then the clause that<br>
mentions "[[Class]]" 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" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><br>
<br clear=3D"all">
<br>
-- <br>
Cheers,<br>
--MarkM<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class=3D"MsoNormal"><br>
<br clear=3D"all">
<br>
-- <br>
Cheers,<br>
--MarkM<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>
--_000_90EDC335A511F2479C63F7337D3CE7DB51179782TK5EX14MBXC116r_--
More information about the es-discuss
mailing list