Quantcast

{this} object literal

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

{this} object literal

Michał Wadas
Hi.

Is there any specific reason why {this} literal is forbidden? Babel had a bug allowing this and it was pretty convenient to enter console.log({this, arguments, externalVar}) for quick printing scope.

Michał Wadas

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: {this} object literal

Sam Gluck
Regardless of whether `this` is permitted as the property name of an object, why not use `console.log(this, arguments, externalVar)`? (Out of interest)

On 21 Apr 2017 6:01 p.m., "Michał Wadas" <[hidden email]> wrote:
Hi.

Is there any specific reason why {this} literal is forbidden? Babel had a bug allowing this and it was pretty convenient to enter console.log({this, arguments, externalVar}) for quick printing scope.

Michał Wadas

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



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: {this} object literal

Gary Guo-2
In reply to this post by Michał Wadas

Because the shorthand only requires an Identifer, and an IdentiferName is not sufficient. If the rule allows arbitrary IdentiferName, then we will also allow `{if}`, which makes no sense it all. So if we really want to allow this, it would be a special rule in addition to the current rule. In this sense, we are not forbidden the use of `{this}`, but instead we don't have the rule to allow that.


From: es-discuss <[hidden email]> on behalf of Michał Wadas <[hidden email]>
Sent: Friday, April 21, 2017 6:01:37 PM
To: [hidden email]
Subject: {this} object literal
 
Hi.

Is there any specific reason why {this} literal is forbidden? Babel had a bug allowing this and it was pretty convenient to enter console.log({this, arguments, externalVar}) for quick printing scope.

Michał Wadas

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: {this} object literal

Claude Pache
In reply to this post by Michał Wadas

More generally, all keywords are excluded, that makes sense in general as, e.g., `{ if }` could not be equivalent to `{ if: if }`, or `{ yield }` inside a generator function should not be equivalent to `{ yield: yield }`.

But yes, one could have special-cases for literals such as `this`, `true`, `false` and `null`. It is an accident of history that `{ NaN }` and `{ undefined }` work as expected, but not `{ null }`.

—Claude

Le 21 avr. 2017 à 19:01, Michał Wadas <[hidden email]> a écrit :

Hi.

Is there any specific reason why {this} literal is forbidden? Babel had a bug allowing this and it was pretty convenient to enter console.log({this, arguments, externalVar}) for quick printing scope.

Michał Wadas
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: {this} object literal

Gary Guo-2
In reply to this post by Michał Wadas

Because the shorthand requires an Identifer, and an IdentiferName is not sufficient. If the rule allows arbitrary IdentiferName, then we will also allow `{if}`, which makes no sense it all. So if we really want to allow this, it would be a special rule in addition to the current rule. In this sense, we are not forbidden the use of `{this}`, but instead we don't have the rule to allow that.


From: es-discuss <[hidden email]> on behalf of Michał Wadas <[hidden email]>
Sent: Friday, April 21, 2017 6:01:37 PM
To: [hidden email]
Subject: {this} object literal
 
Hi.

Is there any specific reason why {this} literal is forbidden? Babel had a bug allowing this and it was pretty convenient to enter console.log({this, arguments, externalVar}) for quick printing scope.

Michał Wadas

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