Russell Leggett wrote:
On Tue, Jul 10, 2012 at 10:40 AM, Brendan Eich <[email protected]
<mailto:[email protected]>> wrote:
Russell Leggett wrote:
Another thing that I was also thinking is that it might look a
little nicer if the ? was a post-fix instead of a pre-fix.
let {first, last, company?} = contact;
I might be missing why this wouldn't work out, but it
aesthetically just looks right to me. It looks like the regex
operator, and is also obviously the position it would be in
english.
We have to parse LHS-of-assignment patterns using the Expression
cover grammar, so this does not work in general due to ?:.
If we parse only in binding contexts (let, const, var on the left,
or formal params and catch clauses), then we could use a different
pattern grammar. Worth breaking uniformity with assignment
expressions?
Right, I've mostly been thinking about only declaration forms of
assignment, however, thinking about it now, wouldn't it be only a
single token of lookahead to disambiguate? A postfix "optional"
operator could only be followed by , ] } or = (when in the value
position) - none of which would be valid tokens for the ternary
operator. If it is on an object property, it could actually be
followed by a :, but that is unambiguous because it is a property, not
an expression.
You're right, we could use lookahead restrictions. Maybe it's worth it
-- Dave (when back from vacation), Andreas and Allen should pipe up.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss