Errors in syntax for array destructuring?

Mike Shaver mike.shaver at gmail.com
Fri Oct 15 11:08:13 PDT 2010


On Fri, Oct 15, 2010 at 8:34 AM, Brendan Eich <brendan at mozilla.com> wrote:
> On Oct 14, 2010, at 11:47 PM, Dominic Cooney wrote:
>
>> On the harmony:destructuring page
>> <http://wiki.ecmascript.org/doku.php?id=harmony:destructuring> it
>> specifies this syntax for patterns:
>>
>> Pattern ::= "{" (Field ("," Field)*)* "}"
>>          | "[" ((Pattern | LValue)? ",")* "]"
>> Field   ::= Identifier (":" (Pattern | LValue))?
>> LValue  ::= <any lvalue expression allowed in a normal assignment expression>
>>
>> Is it intentional that commas aren't required between fields of an
>> object pattern, for example, {x y}? That seems concise, but odd.
>> SpiderMonkey doesn't support this syntax.
>
> There is a comma (",") in the first EBNF production you cite from the wiki, just after the meta-left-parenthesis:
>
>> Pattern ::= "{" (Field ("," Field)*)* "}"

Maybe I'm misreading it too, but I would expect that since the inner
("," Field)* can match the empty string

"{" (Field )* "}"

and therefore as Dominic says just have "{" Field Field Field "}"

Mike


More information about the es-discuss mailing list