On Wed, Jul 11, 2012 at 7:16 AM, Andreas Rossberg <[email protected]>wrote:
> On 10 July 2012 10:47, Russell Leggett <[email protected]> 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. >> > > Even parsing issues aside, I don't like postfix better. It is easier to > miss, especially if ? was possible on patterns, not just properties. > Consider: > > let {the, that: {x, y}, those, theirs: {what, why}, thus}? = > callSomething() > > How easy is it to miss the final '?' when looking for the binding of 'x'? > > But even on longish property names it can be a tad too easy to overlook: > > let {what, why, whatTheHeckIsGoingOn?} = callSomething() > I know what you're saying, but I think it is widely used as postfix. People are used to it. And it reads fine to me here: Pattern ::= "{" (Field ("," Field)* ","?)? "}" | "[" ArrayPatternList "]" ArrayPatternList ::= "..." Element | Element? ("," Element?)* ("," "..." Element)? Element ::= Pattern | LValue Field ::= Identifier (":" Element)? LValue ::= <any lvalue expression allowed in a normal assignment expression> - Russ > > /Andreas > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

