Gus,

Sure, but your (const) example is simply syntactically invalid – syntactically 
invalid code will always be hard for humans to digest. A better example might 
be one involving operator precedence – I’ll plead guilty to adding unnecessary 
parentheses so someone looking at code doesn’t have to waste cycles thinking 
through operator precedence issues.

But, in any case, I don't think human would find:

  let obj = {`foo bar`: 1}

or even

  let obj = {`foo${i}`: 1}

daunting to parse. And if it upsets them, just like I add unnecessary 
parantheses to my code, they could do

  let obj = {[`foo${i}`]: 1}

if they feel that somehow makes the code clearer (it gives me a headache ;-)).

Thanks

------
Alex Kodat
Senior Product Architect
Rocket Software
t: +1 781 684 2294 • m: +1 315 527 4764 • w: http://www.rocketsoftware.com/

From: Gus Caplan <[email protected]>
Sent: Thursday, November 7, 2019 3:13 PM
To: Alex Kodat <[email protected]>
Cc: Jordan Harband <[email protected]>; [email protected]
Subject: Re: Template literal property names in object literals

Syntactic ambiguities are not very representative of what humans find 
ambiguous. For example, `const x = 1 const x = 2` (no semicolon) is not 
ambiguous to a parser at all, but humans have a hard time tracking it.

On Thu, Nov 7, 2019 at 12:53 PM Alex Kodat <mailto:[email protected]> 
wrote:
Jordan,

That’s not an ambiguity, it’s just a rule of thumb that’s currently true. No? 
My question is whether adding TemplateString to ComputedPropertyName in the 
spec would create **syntactic** ambiguities or daunting implementation issues.

Clearly, there's little interest in this so I'll drop it, I was just curious as 
I, at least, was somewhat surprised to see it didn't work.

Thanks

------
Alex Kodat
Senior Product Architect
Rocket Software
t: +1 781 684 2294 • m: +1 315 527 4764 • w: 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2F&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982532174&sdata=wl5HN9LEKavzBGkxJf0SugC2iN2oOQu12kmnXKUkXoo%3D&reserved=0

From: Jordan Harband <mailto:[email protected]>
Sent: Thursday, November 7, 2019 2:44 PM
To: Alex Kodat <mailto:[email protected]>
Cc: Gus Caplan <mailto:[email protected]>; mailto:[email protected]
Subject: Re: Template literal property names in object literals

It would create the ambiguity that "every property name not in brackets is 
static/hardcoded" is no longer true.

On Thu, Nov 7, 2019 at 12:14 PM Alex Kodat 
<mailto:mailto:[email protected]> wrote:
Jordan,

The sentiments in that link discuss the wisdom of having the StringLiteral 
definition include NoSubstitutionTemplate, a question about which I am 
agnostic, and wouldn't provide the full functionality I'm asking about, anyway.

And I also understand that the spec currently only allows computed property 
names in square brackets.

My suggestion was that ComputedPropertyName *could* be changed to include 
TemplateString (without square brackets). Whether this is worth doing or paints 
JS syntax into a corner is a fair question, but I don't see that adding 
TemplateString to ComputedPropertyName would create any syntactic ambiguities 
and wouldn't seem to present daunting implementation issues. But maybe this 
last assertion is incorrect and ambiguities would arise or implementation would 
be a nightmare?

Thanks

------
Alex Kodat
Senior Product Architect
Rocket Software
t: +1 781 684 2294 • m: +1 315 527 4764 • w: 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2F&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982532174&sdata=wl5HN9LEKavzBGkxJf0SugC2iN2oOQu12kmnXKUkXoo%3D&reserved=0

From: Jordan Harband <mailto:mailto:[email protected]>
Sent: Thursday, November 7, 2019 1:46 PM
To: Alex Kodat <mailto:mailto:[email protected]>
Cc: Gus Caplan <mailto:mailto:[email protected]>; 
mailto:mailto:[email protected]
Subject: Re: Template literal propery names in object literals

Anything dynamic - computed - should be in brackets, since that's what that 
indicates.

Thus, template literals with substitutions must require brackets.

Based on sentiments like 
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftc39%2Fecma262%2Fissues%2F1399%23issuecomment-452910799&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982542161&sdata=V%2BzJuiHgRE6plHXA5lyY4xhlhv4O5%2Fvl6UTc1yeaRzk%3D&reserved=0,
 either all template literals or none should be permitted in a given position.

Thus, no change is possible.

On Thu, Nov 7, 2019 at 10:00 AM Alex Kodat 
<mailto:mailto:mailto:mailto:[email protected]> wrote:
Thanks Gus,

Good stuff. Though I think I’d take a different tack on the discussion at that 
link, especially as I think the template literals should allow substitutions 
(why not?):

let obj = { `${Date()}`: 1};

I guess the tack I would take in the spec would be to add TemplateLiteral to 
ComputedPropertyName and not worry about whether or not it's a 
NoSubstitutionTemplate.

Thanks

------
Alex Kodat
Senior Product Architect
Rocket Software
t: +1 781 684 2294 • m: +1 315 527 4764 • w: 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2F&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982542161&sdata=oWJOeksC4idx7j4ffoOjNMiT6oXmY8XmVaAgQJnmHPM%3D&reserved=0

From: Gus Caplan <mailto:mailto:mailto:[email protected]>
Sent: Thursday, November 7, 2019 11:13 AM
To: Alex Kodat <mailto:mailto:mailto:mailto:[email protected]>
Cc: mailto:mailto:mailto:mailto:[email protected]
Subject: Re: Template literal propery names in object literals

Related discussion 
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftc39%2Fecma262%2Fissues%2F1399&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982552157&sdata=Lm5ZzlaIBiRhWfI%2B3NM7q6WN4R9zeDtak5eb1L8nD5A%3D&reserved=0

On Thu, Nov 7, 2019 at 8:46 AM Alex Kodat 
<mailto:mailto:mailto:mailto:mailto:mailto:mailto:[email protected]> 
wrote:
Just curious. Is there a reason template literals are not allowed as property 
names in object literals? I can do:

   let obj = {'foo bar': 1};

and

   let obj = {"foo bar": 1};

but not

   let obj = {`foo bar`: 1};

It doesn't seem that allowing the latter would present any syntactic problems 
and seems like almost an oversight that it's not allowed.

The main reason I ask is that we've gone completely over to using template 
literals for all our literals (why not?) and was surprised that we can't use a 
template literal as an object literal property name. Obviously, we can do:

   let obj = {[`foo bar`]: 1};

And given that square brackets allow arbitrary expressions for propery names, 
it wouldn't seem that supporting template literals for object literal property 
names would not present any daunting implementation issues.

I guess I'd argue that the Principle of Least Astonishment and/or completeness 
suggests that JS should support this.

Sorry if this has been asked before but couldn't find anything in the archive.

Thanks

------
Alex Kodat
Senior Product Architect
Rocket Software
t: +1 781 684 2294 • m: +1 315 527 4764 • w: 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982562151&sdata=mqg7YqYTO6HUqPrqCE1M3NKOtgGAWCf9OOYfTosN0kg%3D&reserved=0

================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmy.rocketsoftware.com%2FRocketCommunity%2FRCEmailSupport&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982562151&sdata=B69PJqlsl6nBt%2FFpX3j05uo4KR71TT0EDelw5e7at5k%3D&reserved=0
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fmanage-your-email-preferences&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982572144&sdata=fMfK6iYnNZPmtOQiUOeoxSO7w0bpGEb0LdNbPReKFko%3D&reserved=0
Privacy Policy - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fcompany%2Flegal%2Fprivacy-policy&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982572144&sdata=I47ddmdxHISIAkZ1Mv%2Fb13jaI2eJRhekdiT7pu4x%2B6Q%3D&reserved=0
================================

This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
_______________________________________________
es-discuss mailing list
mailto:mailto:mailto:mailto:mailto:mailto:mailto:[email protected]
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.mozilla.org%2Flistinfo%2Fes-discuss&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982582151&sdata=ANCtddCkLNrPTrRqhf%2FZ8mQMCRuKONF85%2B3SZXvObnw%3D&reserved=0
================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmy.rocketsoftware.com%2FRocketCommunity%2FRCEmailSupport&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982582151&sdata=v7b3tpR4ppPgfcCoy32cVwHRXHNdCfBdLIBR2mc%2FrdE%3D&reserved=0
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fmanage-your-email-preferences&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982592136&sdata=gbFTs%2Bu0JRcF%2FMJyELe2WgwO9M9TwFduw56qOD%2FfKqU%3D&reserved=0
Privacy Policy - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fcompany%2Flegal%2Fprivacy-policy&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982592136&sdata=EfUMcoOuFQ%2Bz8X%2FC3QhscV34aY92f50bj%2FlJ8q3QOTI%3D&reserved=0
================================

This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
_______________________________________________
es-discuss mailing list
mailto:mailto:mailto:mailto:[email protected]
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.mozilla.org%2Flistinfo%2Fes-discuss&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982602130&sdata=bw0P7yTltDLYuKV7n3MHDDwNXBgG1S53R9pgB9md%2Fhs%3D&reserved=0
================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmy.rocketsoftware.com%2FRocketCommunity%2FRCEmailSupport&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982602130&sdata=6z4ZyLpLm4AVesMLlF7HmnZCEf%2FTD%2BHeTMXGHU2%2BsqY%3D&reserved=0
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fmanage-your-email-preferences&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982612127&sdata=57i9MjdsALYucdvdN%2FtRxjJR3cnVyyDeQiF8OSgFRNU%3D&reserved=0
Privacy Policy - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fcompany%2Flegal%2Fprivacy-policy&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982622116&sdata=a%2BQxLb5kZe0PzHEKPowOr3y%2BtCAelFAfUbv3Rh0cOAg%3D&reserved=0
================================

This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmy.rocketsoftware.com%2FRocketCommunity%2FRCEmailSupport&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982622116&sdata=WQohVn%2B9zxAtp10RvyT6BW%2Bf1G36qHp9sii6foM5g68%3D&reserved=0
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fmanage-your-email-preferences&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982632109&sdata=b84gMNTHHrwfbXNEDzMj7D%2FCAsyv2KLY1Lj%2BiJiquz4%3D&reserved=0
Privacy Policy - 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.rocketsoftware.com%2Fcompany%2Flegal%2Fprivacy-policy&data=02%7C01%7C%7Ce77faaad7c8444d9792f08d763c74e54%7C79544c1eed224879a082b67a9a672aae%7C0%7C1%7C637087579982632109&sdata=N8FK8kg6VpSTOBke39a4mRqBZX8hCNo574pThNHWAKI%3D&reserved=0
================================

This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy
================================

This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to