Can Activation Object have a [[Prototype]]?
On Dec 28, 2009, at 8:48 PM, Garrett Smith wrote:
Can Activation Object have Object.prototype for [[Prototype]]?
Absolutely not, for the reason you illustrate with the toString example.
The only implmeentation I know of that does this is Blackberry9000. I called it a bug, but now I am not sure. Is this behavior disallowed by the specification? If so, where?
An Activation object is an internal (abstract, only for the spec, not
detectable in the language) object. If you could detect its presence,
e.g. by its having a [[Prototype]] internal property with non-null
value, then the implementation would not conform. See ES3 10.1.6:
"The activation object is purely a specification mechanism. It is
impossible for an ECMAScript program to access the activation object.
It can access members of the activation object, but not the activation
object itself. When the call operation is applied to a Reference value
whose base object is an activation object, null is used as the this
value of the call."
ES5's Clause 10 eliminates all mention of "activation objects" and
avoids abusing objects for internal (spec-only) data types.
On Mon, Dec 28, 2009 at 9:29 PM, Brendan Eich <brendan at mozilla.com> wrote:
On Dec 28, 2009, at 8:48 PM, Garrett Smith wrote:
Can Activation Object have Object.prototype for [[Prototype]]?
Absolutely not, for the reason you illustrate with the toString example.
The only implmeentation I know of that does this is Blackberry9000. I called it a bug, but now I am not sure. Is this behavior disallowed by the specification? If so, where?
An Activation object is an internal (abstract, only for the spec, not detectable in the language) object. If you could detect its presence, e.g. by its having a [[Prototype]] internal property with non-null value, then the implementation would not conform. See ES3 10.1.6:
"The activation object is purely a specification mechanism. It is impossible for an ECMAScript program to access the activation object. It can access members of the activation object, but not the activation object itself. When the call operation is applied to a Reference value whose base object is an activation object, null is used as the this value of the call."
That says that a program cannot access the activation object. It does not say that activation object cannot have a [[Prototype]].
ES5's Clause 10 eliminates all mention of "activation objects" and avoids abusing objects for internal (spec-only) data types.
Thanks. I remember reading about "Lexical Environment" but did not see a provision expressly prohibiting a "Lexical Environment" from being implemented as a native object. Its crazy to do that, but there it is in Blackberry9000. If you're an admirer of bugs, you've got to love that one.
Garrett
On Dec 28, 2009, at 10:43 PM, Garrett Smith wrote:
On Mon, Dec 28, 2009 at 9:29 PM, Brendan Eich <brendan at mozilla.com>
wrote: That says that a program cannot access the activation object. It does not say that activation object cannot have a [[Prototype]].
If it did, then you could detect the existence of Activation objects,
even though they are inaccessible due to |this| censoring (null
replacement, followed by "the global object" replacing null).
You're right the wording was too narrow, though. Fixed in ES5, at
least (the Blackberry implementation almost certainly predates ES5 or
ES3.1 language that eliminated "activation objects").
Can Activation Object have Object.prototype for [[Prototype]]?
I don't see it explicitly outline in ES3. ES5 uses Lexical Environment terminology instead.
If Activation Object has a [[Prototype]] as Object.prototype, then identifiers can be resolved on the activation object.
var toString = 12; function x(){ alert( toString ); }
And so the problem would be that if toString were resolved on the activation object's [[Prototype]] instead of containing scope, the result would not be 12, but would be Object.prototype.toString.
The only implmeentation I know of that does this is Blackberry9000. I called it a bug, but now I am not sure. Is this behavior disallowed by the specification? If so, where?
Garrett