new instantiation design alternatives

Allen Wirfs-Brock allen at
Wed Sep 17 11:08:58 PDT 2014

On Sep 17, 2014, at 7:24 AM, Kevin Smith wrote:

> That's not true, is it? Assuming someone (e.g. B) actually assigns a property of `this`, an error will occur (or worse, a global will be created, in sloppy mode).
> Sorry, when I say "called", I mean called with a proper "this" variable.
> Under the current system, constructors work as "this" initializers, with or without "new".  Hopefully that explains my meaning a little better.

Justin case there is any confusion about this, let me remind everyone, that under both of the currently proposed alternatives nothing changes from the current behavior for "basic constructors" (ie, constructors defined using `function` definitions.  They always allocated and bind `this` to a new ordinary object when invoked via [[Construct]].  See 
Just like in ES1-5.

It's only constructors defined within class definitions that have new behavior of (possibly entering the body with `this` in the TDz).  I another variation of the design (I call it alternative #3 or Domenic's variation since we suggested it) is to treat class constructors just like basic constructor and always allocate and this-bind an ordinary object on a [[Construct]]. It's a plausible alternative but also has a few pros and cons.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list