Re: Computed Property Name Shorthand Proposal
Alexander Jones wrote: That's exactly what this is. I appreciate the beauty in symmetry, but I think -1. I second this. On 27 August 2015 at 17:25, Kevin Smith zenpars...@gmail.com mailto:zenpars...@gmail.com wrote: I'd expect the following to work, given that the prop expression evaluates to 'bar', and bar is in context. var foo = 'bar' var bar = 'ponyfoo' var baz = { [foo] } console.log(baz) // - { bar: 'ponyfoo' } Hmmm... I'm not sure I would expect any such thing. It seems like you're proposing some kind of dynamic eval-ish variable binding lookup, which is probably going to be a no-go. Kevin ___ es-discuss mailing list es-discuss@mozilla.org mailto:es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Computed Property Name Shorthand Proposal
That's exactly what this is. I appreciate the beauty in symmetry, but I think -1. On 27 August 2015 at 17:25, Kevin Smith zenpars...@gmail.com wrote: I'd expect the following to work, given that the prop expression evaluates to 'bar', and bar is in context. var foo = 'bar' var bar = 'ponyfoo' var baz = { [foo] } console.log(baz) // - { bar: 'ponyfoo' } Hmmm... I'm not sure I would expect any such thing. It seems like you're proposing some kind of dynamic eval-ish variable binding lookup, which is probably going to be a no-go. Kevin ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Computed Property Name Shorthand Proposal
I'm usually lousy at interpreting the spec (yet here I go!), but I think the behavior is explained here [1]: PropertyDefinition[Yield] : IdentifierReference[?Yield] CoverInitializedName[?Yield] PropertyName[?Yield] : AssignmentExpression[In, ?Yield] MethodDefinition[?Yield] PropertyName[Yield,GeneratorParameter] : LiteralPropertyName [+GeneratorParameter] ComputedPropertyName [~GeneratorParameter] ComputedPropertyName[?Yield] LiteralPropertyName : IdentifierName StringLiteral NumericLiteral ComputedPropertyName[Yield] : [ AssignmentExpression[In, ?Yield] ] There are aspects to that grammar that I don't fully grok yet, but your `{ [foo] }` example appears to be trying to combine the `IdentifierReference` form (which *doesn't support* an `AssignmentExpression`) and the `PropertyName: AssignmentExpression` form (which *requires* the `AssignmentExpression`). In other words, all paths in that grammar that lead to a ` ComputedPropertyName` being valid also require the right-hand ` AssignmentExpression`. [1] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer On Thu, Aug 27, 2015 at 12:25 PM, Kevin Smith zenpars...@gmail.com wrote: I'd expect the following to work, given that the prop expression evaluates to 'bar', and bar is in context. var foo = 'bar' var bar = 'ponyfoo' var baz = { [foo] } console.log(baz) // - { bar: 'ponyfoo' } Hmmm... I'm not sure I would expect any such thing. It seems like you're proposing some kind of dynamic eval-ish variable binding lookup, which is probably going to be a no-go. Kevin ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss -- Jeremy Martin 661.312.3853 http://devsmash.com @jmar777 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Computed Property Name Shorthand Proposal
I'd expect the following to work, given that the prop expression evaluates to 'bar', and bar is in context. var foo = 'bar' var bar = 'ponyfoo' var baz = { [foo] } console.log(baz) // - { bar: 'ponyfoo' } Hmmm... I'm not sure I would expect any such thing. It seems like you're proposing some kind of dynamic eval-ish variable binding lookup, which is probably going to be a no-go. Kevin ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss