On Jan 17, 2015, at 11:57 AM, Fabrício Matté wrote:

> > Currently in ES6, the only reserved keywords that can appear immediately 
> > before a `.` are `this` and `super`.   
> 
> The `this` binding resolves to a value, so MemberExpressions make sense. The 
> `super` keyword is being implemented in ES6, so there are no precedents to 
> set expectations.
> 
> > Any other reserved word followed by a `.` is a syntax error.  So reserved 
> > words followed by period and an identifier is  one of the few available 
> > extension alternatives we have available.  And is a natural ready syntax 
> > think of new.target' as meaning give me the target value of the currently 
> > active `new` operator.
> 
> I agree `new.target` is very natural and pleasant to read. It just feels 
> rather alien to see an operator in the beginning of a MemberExpression, which 
> currently would only be allowed in this very specific scenario. Of course, if 
> this syntax extension form would be useful for other use cases as Kevin and 
> you have outlined, then I don't oppose it.
> 
> > I suspect the hypothetical naive JS programmer postulated above wound't be 
> > aware of any of those concepts.
> 
> A naive one probably not, but a curious avid developer most definitely would. 
> ;)
> 
> > hopefully they will say what is `new.target', "google it" and immediately 
> > find the answer.
> 
> You mean, land on a Stack Overflow answer with thousands of upvotes and very 
> little explanation about why/how a MemberExpression can begin with an 
> operator. Of course, if you interpret `new` as simply a ReservedWord token 
> instead of an operator, then everything makes perfect sense.


The way I accomplish in the grammar was to add the productions:

MemberExpression : 
      MetaProperty
MetaProperty :
       'new'    '.'   'target'

So we could start talking about "meta properties" as a MemberExpression 
alternative and say `new.target` is a "meta property".

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

Reply via email to