[[Class]] and host objects
Allen.Wirfs-Brock at microsoft.com
Fri Feb 6 17:01:11 PST 2009
At the Mountain view meeting we agreed to "remove the host object exemption" regarding [[Class]] so we could reliably use it discriminate "types" of objects. I'm trying to implement this in the specification, but what does it really mean?
ES3 currently says: "The value of the [[Class]] property of a host object may be any value, even a value used by a built-in object for its [[Class]] property." (8.6.2). This is the exemption we agreed to remove.
If we simply remove this sentence there is still an explicitly statement requirement that all host objects must have a [[Class]] property but there is then no guidance at all about what is allowable as its value. That might be interpreted to mean pretty much the same thing as the deleted sentence.
I assume that we wanted to allow under some circumstances for host objects to have a [[Class]] value that is the same as one of the built-in values ("Object" comes to mind ). If so, what are those circumstances. Short of explicitly enumerating all the invariants that must be satisfied for each built-in [[Class]] value is there any way to express when a host object is allowed to use of these values?
My first cut was to replace the ES3 sentence with: "The value of the [[Class]] property of a host object may be any String value. However, if a host objects has a [[Class]] property whose value is the same as that defined by this specification for a built-in object then the host object must conform to all requirements associated with that built-in object."
But what does that really mean. Which "requirements" are we talking about? That the host object must fully implement the Section 15 specification of the corresponding built-in object? In that case, isn't such a host object really just a way to implement the native object. In other words, it's actually a native object not a host object at all? In that case we probably also don't need to say anything.
Is it really the intent that any object whose [[Class]] is "Array" must fully implement 15.4.5? One of the things that 15.4.5 says is that array instances inherit from the original Array prototype object. Is this a requirement of [[Class]]=="Array"? If so, what about array objects that come from different contexts that have a different Array prototype object? Is the requirement really only that "Array" objects implement the special [[ThrowingPut]] method defined in 184.108.40.206.
I've tried various formulation of a simple statement about host objects but I keep finding potential holes and coming back to the conclusion that the only meaningful thing to do is to explicitly enumerable the invariants associated with each predefined [[Class]] value. Does anybody have a simpler solution? Does anybody want to volunteer to identify the invariants?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Es-discuss