Allen Wirfs-Brock (2015-01-16T20:13:22.000Z)
err, 
         try {
              let thisValue = this;  //can't reference 'this' prior to 'super()' in a [[Construct]] call of a derived function
         } catch (e} {
            calledAsFunction = false  //no let here
        }



On Jan 16, 2015, at 12:02 PM, Allen Wirfs-Brock wrote:

> 
> On Jan 16, 2015, at 11:40 AM, Kevin Smith wrote:
> 
>> Changes include: Updated specification to use and support the new built-in subclassing scheme described at: https://github.com/tc39/ecma262/blob/master/workingdocs/ES6-super-construct%3Dproposal.md
>> 
>> This looks nice.  An interesting question:
>> 
>> For classes that have divergent [[Construct]]/[[Call]] behavior, should the [[Call]] behavior be "inherited" by derived classes?
>> 
>>     class MyDate extends Date {}
>>     console.log(MyDate(1, 2, 3));  A string, or throw an error?
>> 
>> 
> 
> Since the above class definition does not include an explicit constructor body, it gets the equivalent of
>    constructor(...args) {super(...args)}
> as its implicit constructor definition
> 
> A 'super()' call throws if the NewTarget is null (ie, if the constructor is invoked via [[Call]] )
> 
> If you want to inherit call behavior you need to code it as:
> 
>   class MyDate extends Date {
>      constructor(...args) {
>          if (new.target===null) return super.constructor(...args)
>          super(...args);
>       }
> }
> 
> That's assuming 'new.target' makes it into ES6.  Without it you would have to do something like:
> 
>   class MyDate extends Date {
>      constructor(...args) {
>          let calledAsFunction=true;
>          try {
>               let thisValue = this;  //can't reference 'this' prior to 'super()' in a [[Construct]] call of a derived function
>          } catch (e} {
>             let calledAsFunction = false
>         }
>         if (calledAsFunction) return super.constructor(...args)
>         super(...args);
>       }
> }
> 
> Allen
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150116/69ba6eb8/attachment.html>
d at domenic.me (2015-01-28T19:27:37.852Z)
err,

```js
try {
    let thisValue = this;  //can't reference 'this' prior to 'super()' in a [[Construct]] call of a derived function
} catch (e} {
    calledAsFunction = false  //no let here
}
```