Question of destructuring
On Nov 8, 2008, at 9:40 AM, Eric Suen wrote:
developer.mozilla.org/en/New_in_JavaScript_1.7
has following statement:
for each (let {name: n, family: { father: f } } in people) { print ("Name: " + n + ", Father: " + f + "<br>\n"); }
But in www.ecmascript.org/es4/spec/grammar.pdf
ForInBinding ::= Pattern | VariableDefinitionKind VariableBinding
VariableBinding ::= TypedIdentifier | TypedPattern VariableInitialisation
VariableInitialisation ::= '=' AssignmentExpression
Obviously "let {name: n, family: { father: f } }" is not a Pattern, So, how the above statement is valid?
It's a bug, thanks for pointing it out. The ES4 grammar is not being
maintained now AFAIK. Cc'ing Jeff.
Will destructuring and closures be included in ES3.1?
Where can I find the grammar of destructuring and closures in mozilla JavaScript 1.8, because in mozilla docs site only list some examples, that is not enough for write a parser.
,
Eric Suen
----- Original Message ---
On Nov 9, 2008, at 12:24 AM, Eric Suen wrote:
Will destructuring and closures be included in ES3.1?
("closures" I take to mean expression closures -- please correct me if
I'm misreading you.)
No, and this should be clear to anyone following the es*-discuss lists
(either list -- but you have to read all the messages). The draft
ES3.1 specs make clear what's in or maybe-in, and we've had many
messages (including very recently) about ES3.1 ins and outs.
Where can I find the grammar of destructuring and closures in mozilla JavaScript 1.8, because in mozilla docs site only list some examples, that is not enough for write a parser.
You'll have to read the source for SpiderMonkey or Rhino (both
implement these now, I believe).
developer.mozilla.org/en/New_in_JavaScript_1.7
has following statement:
for each (let {name: n, family: { father: f } } in people) { print ("Name: " + n + ", Father: " + f + "<br>\n"); }
But in www.ecmascript.org/es4/spec/grammar.pdf
ForInBinding ::= Pattern | VariableDefinitionKind VariableBinding
VariableBinding ::= TypedIdentifier | TypedPattern VariableInitialisation
VariableInitialisation ::= '=' AssignmentExpression
Obviously "let {name: n, family: { father: f } }" is not a Pattern, So, how the above statement is valid?
,
Eric Suen