new instantiation design alternatives
jason.orendorff at gmail.com
Thu Sep 18 08:36:29 PDT 2014
On Tue, Sep 16, 2014 at 6:48 PM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
> On Sep 16, 2014, at 12:57 PM, Brendan Eich wrote:
>> Allen Wirfs-Brock wrote:
>>> We have long standing consensus on the current ES6 class design and that includes a `super()` constructor call that can be arbitrarily placed within the constructor body.
>> I'm ok with consensus if it's real and strong. We aren't there yet, and AFAIK we never had cow-path-based use-cases for super calls tucked into the middle of constructors. We definitely had concerns about uninitialized objects, and people wanted to deal with constructor called as function. But conditional super()? I don't remember that.
> The ES6 max-min class and @@create instantiation proposals have always allowed arbitrarily placed `super` calls in methods (and up until the recent discussions) we treated class constructors as just the `constructor` method of the class prototype. The cow path for arbitrarily placed method super` is well paved and supports the fully generality of before, after, and around specialization in over-riding subclass methods without requiring additional syntactic affordance. It's a cow path that is about as old as OO programming and is just as applicable to constructor methods as to any other kind of method.
I don't think this is really correct. As far as I can tell, the
established pattern is
- languages that reveal uninitialized objects (Python, Ruby) allow
base-class constructor calls anywhere
- languages that ensure the base-class constructor is called (C#, C++,
Java) require it to be called up front
The proposed changes make ES fall in neither category.
More information about the es-discuss