new snd super running different code, proposal to fix.

Herby Vojčík herby at
Sun Dec 9 00:19:10 PST 2012


I am doing a little fix in my proposal, [[GetOwn]] was too nannyish, 
[[Get]] is right.

Herby Vojčík wrote:
> So the [[Construct]] should look like this:
> 1) Let creator be Foo.[[Get]](@@create)
> 2) Let newObj be //Foo is passed as the this value to
> @@create
> 3) Let proto be Foo.[[Get]]("prototype")
> 4) Fail if problem.
> 5) If there is [[ProperClass]] in proto, then
> 5.1) Let ctor be proto.[[GetOwn]]("constructor")
5.1) Let ctor by proto.[[Get]]("constructor")
> 5.2) Throw "Not constructible" if not present.
> 6) Else
> 6.1) Let ctor be Foo
> 7) Let ctorResult be ctor.[[call]](newObj,args)
> 8) If Type(ctorResult) is Object, return ctorResult
> 9) else return newObj

When someone consciously deletes "constructor" from [[ProperClass]], it 
is ok and he is thus consciously saying "just do the inherited one".

Which is really great feature! With this proposal, there is no real need 
to generate default constructors, they are included for free (simply do 
not include "constructor" in [[ProperClass]] and inherited one will be 
used). I see this as sign that this proposal of "new" semantic is on the 
right track.


More information about the es-discuss mailing list