Allen Wirfs-Brock (2015-01-17T17:30:58.000Z)
On Jan 17, 2015, at 5:59 AM, Frankie Bagnardi wrote:

> I'm also expecting a lot of questions about 'what is this new.target thing in this code?', 'is new a variable?', 'where does it come from?', 'isn't new an operator?', etc.

as proposed,
`new.target` is a MemberExpression consisting of  the three token sequence `new`  `.`  `target`
If is only allowed in function code.
If the enclosing function is invoked as a call expression the value of  `new.target` is null
   `(function() {assert(new.target===null)})()
if the enclosing function is directly invoked as a constructor via `new` the value of `new.target` is the function 
```js 
    function f() {assert(new.target===f)}
    new f();
```
if the enclosing function is indirectly invoked as a constructor via `super()` or `new super()` the value of `new.target` is  the function new was directly applied to
```js 
    class Super  { constructor() {assert(new.target===Sub)}}
    class Sub extends Super {constructor() {super()}}
    new Sub();
```

> 
> if (this instanceof MyDate) ...
> 
> ... is clearer, but I guess it needs to be disallowed because of the other rules.

When a function is called (rather than new'ed) its this value is usually undefined (assuming a strict function)

Allen


> 
> On Fri, Jan 16, 2015 at 1:29 PM, Brendan Eich <brendan at mozilla.org> wrote:
> Gotta agree new.target is nicer to read and write!
> 
> /be
> 
> Allen Wirfs-Brock wrote:
> 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
>         }
> 
> _______________________________________________
> 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/20150117/78913647/attachment.html>
d at domenic.me (2015-01-28T19:28:39.538Z)
On Jan 17, 2015, at 5:59 AM, Frankie Bagnardi wrote:

> I'm also expecting a lot of questions about 'what is this new.target thing in this code?', 'is new a variable?', 'where does it come from?', 'isn't new an operator?', etc.

as proposed, `new.target` is a MemberExpression consisting of  the three token sequence `new`  `.`  `target`

It is only allowed in function code.

If the enclosing function is invoked as a call expression the value of  `new.target` is null

```js
(function() {assert(new.target===null)})()
```

if the enclosing function is directly invoked as a constructor via `new` the value of `new.target` is the function 

```js 
function f() {assert(new.target===f)}
new f();
```

if the enclosing function is indirectly invoked as a constructor via `super()` or `new super()` the value of `new.target` is  the function new was directly applied to

```js 
class Super  { constructor() {assert(new.target===Sub)}}
class Sub extends Super {constructor() {super()}}
new Sub();
```

> 
> if (this instanceof MyDate) ...
> 
> ... is clearer, but I guess it needs to be disallowed because of the other rules.

When a function is called (rather than new'ed) its `this` value is usually undefined (assuming a strict function)