This has been suggested previously, but shot down on the grounds of 
performance (and difficulties with the way the Parser allocates variables, 
etc). However, I'm bringing it up again, as it seems to be working well for 
other implementations:

Currently, JavaScriptCore has the novel concept of saving a position in the 
token stream, and rewinding back to it if necessary.

They are currently doing this at the start of every AssignmentExpression, 
which begins with a peeked LBRACK or LBRACE, and which is not followed by 
an ASSIGN token. It would follow that you'd also want to do this for 
parenthesized Expressions that may be Arrow formals, although I don't see 
this happening in their current implementation.

It's been suggested that V8 does this before, but has been shot down each 
time --- however, it looks like it potentially solves two problems:

1. the cover grammars may be parsed specially, rather than requiring 
particular productions handle parsing several different ways 
simultaneously, and drastically simplifying the parser
2. it is possible to correctly ensure that appropriate code is produced. 
Since the Parser is performing the desugaring (which does not occur in 
JSC), eagerly rewriting AssignmentExpressions as destructuring assignment 
can produce an AST which the BindingPattern rewriter simply can't deal 
with, and which would be difficult for it to deal with.

Might be worth coming back to the topic if it works well for other 
implementations, which still seem to perfectly adequately compile JS on the 
web.

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to