new instantiation design alternatives

Allen Wirfs-Brock allen at wirfs-brock.com
Thu Sep 18 13:51:43 PDT 2014


On Sep 18, 2014, at 1:30 PM, Domenic Denicola wrote:

> From: Allen Wirfs-Brock [mailto:allen at wirfs-brock.com] 
> 
>> But that won't give you a real HTMLElement exotic object, if there is such a thing, and won't initialize it properly.
>> 
>> But you can get around that problem if the HTMLElement constructor is defined appropriately using this^:
> 
> That's a good point, thanks for explaining. (I assume you mean `new^`? You keep saying `this^` here and in other messages so I wonder if you've had a shift in thinking.)
> 
> At this point my only real argument for implicit `this = Object.create(new^.prototype)` is that it's what happens with function-based inheritance. I agree with Dmitry that there probably is no good default so I guess I just find taking cues from what functions do to be the best guidance. But requiring explicit initialization seems fine too.
> 

yes,  but basic function constructors are the equivalent of class definitions without an extends clause.  It's been suggested that an optional extends clause that `function` could someday be added to function definitions:

if we did that, we would probably apply the same rules as for subclasses with an extends.  But it probably actually isn't needed.  When you look closely, the semantics of 

class Foo extends Bar {
   constructor () {}
}

are exactly what we would defined for 

function Foo() extends Bar {
}

so it adds no know expressiveness.

Allen 


More information about the es-discuss mailing list