On Jun 18, 2014, at 11:09 AM, Brendan Eich wrote:

> Allen Wirfs-Brock wrote:
>> This is also one of my bigger concerns.  I think the rewriting and 
>> reinterpretation of what the use wrote as a a constructor may be very 
>> problematic.   For example,how does this get translated:
>> 
>> class extends C {
>>  constructor() {
>>       super();
>>       super.foo();  //apply the inherited foo method to the new object
>>  }
>> }
>> 
>> If we had a design that didn't require the rewriting of the user provided 
>> constructor I'd be much more comfortable.  Thinking...more latter...
> 
> I used to think this way, but dherman pointed out years ago that constructor 
> in ES6 class is a special form, even though it looks like a method. Here's an 
> es-discuss thread from three years ago:
> 
> http://esdiscuss.org/topic/why-not-new-instead-of-constructor

Except in the current design there is no special reinterpretation of the 
constructor method body semantics.  The constructor method definition simply 
provides body of the constructor function and semantically is exactly the same 
as the body that is provided in a Function definition. See 
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-classdefinitionevaluation
 and in particular step 10 which calls 
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-definemethod
 which just calls 
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-functioncreate .  No 
special processing of the body anywhere along that path.  The only special 
treatment prior to step 10 is about choosing a default constructor body if a 
constructor method isn't provided in the class declaration.

It is an alternative syntax for providing a the body of a function, but it has 
no unique semantics.  That seems significant to me.

Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to