brendan at mozilla.com
Thu Mar 12 19:28:59 PDT 2009
On Mar 12, 2009, at 7:13 PM, Brendan Eich wrote:
> On Mar 12, 2009, at 6:45 PM, Tobie Langel wrote:
>> A very naïve specification would boil down to modifying step 2 and
>> inserting a step 3 inside of 13.2.2 of the 23feb09 draft:
>> 13.2.2 [[Construct]]
>> When the [[Construct]] property for a Function object F is called
>> with a possibly empty list of
>> arguments, the following steps are taken:
>> 1. Let obj be a newly created native ECMAScript object.
>> 2. if the name property of F is a string value set the [[Class]]
>> internal property of obj to the name property of F.
>> 3. if the name property of F is not a string value set the
>> [[Class]] internal property of obj to "Object".
> From the point of view of implementors, setting the "vtable" for an
> instance is not going to be done based on a string value in a
> property of F. In either case (step 2 or 3) the same implementation
> code for generic Object behavior, appropriate to [[Class]] "Object"
> in ES1-3, will be chosen. The only difference that matters (correct
> me if I'm wrong) is the output of Object.prototype.toString.call(obj).
One more point representing implementors everywhere ;-).
The steps in 13.2.2 do not require storing a link to the constructor
function directly in the new instance. This is the point I mentioned
going over in 1997 during ES1 standardization. Generally while objects
have a fixed number of fields to set on creation, including
[[Prototype]] and [[Class]], they do not have [[Constructor]] or
[[ClassName]]. We don't want to add to the mandatory short-list (which
is [[Prototype]] and [[Class]], [[Scope]] too for function and certain
What you want is for Object.prototype.toString.call(obj) to return
F.name. That could be specified by changing Object.prototype.toString,
instead of 13.2.2. I don't have time to try it out and see how it
works, but I thought I'd suggest it. The constructor property is
writable and deletable, which indeed creates a hazard. But it may be
More information about the Es-discuss