new instantiation design alternatives
rossberg at google.com
Wed Sep 17 10:15:57 PDT 2014
On 17 September 2014 19:04, Brendan Eich <brendan at mozilla.org> wrote:
> I agree with Domenic that any derived-class constructor that needs to
> allocate with specific arguments *and* that must distinguish new'ing from
> calling should have to write an if-else. That's a hard case, EIBTI, etc.
I agree. In fact, I don't see a reason to make it even that simple. My
understanding was that there is wide agreement that invoking
constructors without 'new' should be discouraged, and that functions
behaving differently for Call and Construct are considered a legacy
anti-pattern. In the light of that, I'm stilling missing the
compelling reason to introduce new^ at all. In particular, since TDZ
for `this` allows you to make the distinction fairly easily even
without a new construct, if you are so inclined.
More information about the es-discuss