Optional brackets around lambda expression
Reinier Zwitserloot
reinier at zwitserloot.com
Fri Jun 17 03:07:22 PDT 2011
On Fri, Jun 17, 2011 at 10:49 AM, Bob Foster <bobfoster at gmail.com> wrote:
> This would be no problem for a PEG. Isn't the whole idea that you can't
> look
> ahead a bit somewhat outmoded?
>
>
Sure. I'd raise an eyebrow at anyone who sets out to write a parser for a
new language today who doesn't use something like Parboiled. Nevertheless, a
lot of existing parsers for complex grammars are written in ANTLR or some
handrolled LL(k) variant, most notably including ecj and javac.
Pragmatically speaking, making java (the language) virtually impossible to
parse with a limited lookahead parser means a major delay for that release
of the JDK, and likely a half-a-year+ delay between that JDK's release and
an eclipse version that can deal with it. (same for IntelliJ? I know it has
its own parser, no idea how it works though).
I'd guess that very few syntax improvements warrant that kind of headache.
foo(a,b,c,d,e->f) is very ambiguous; you can group the commas so that any
number of 'arguments' are arguments to the method invocation, and the
remainder are parameters to the closure. With a PEG (sometimes known as an
RD parser, for those googling) you can set up the grammar so that one has
precedence over the other and thus solve this ambiguity, but humans have to
be able to parse that correctly as well.
So, this plan in general is broken as far as I can tell. (and in fairness to
Ali, not what he suggested in the first place).
More information about the lambda-dev
mailing list