That hash symbol

Mike Samuel mikesamuel at gmail.com
Tue Mar 29 16:06:16 PDT 2011


2011/3/29 Bob Nystrom <rnystrom at google.com>:
> Wouldn't => work the same way?
>     (a, b) =>
> It parses "(a, b)" thinking it's a grouped comma operator (not exactly a
> common expression FWIW), then it hits "=>" realizes it's a function
> parameter decl, and then either backtracks or just transforms the left-hand
> AST into a param decl.

An AST won't cut it.  You have to use a parse tree because there are
valid grouped comma operators containing only identifier operands that
are not valid parameter lists, e.g. ((a), b)

Once you do have a way to make the necessary distinctions, => is just
another right associative operator that you need to pick a precedence
for.


More information about the es-discuss mailing list