[Haskell-cafe] Haskell grammar ambiguity

Sven Panne svenpanne at gmail.com
Wed Jun 16 07:48:06 UTC 2021

Am Mi., 16. Juni 2021 um 08:47 Uhr schrieb Li-yao Xia <lysxia at gmail.com>:

> [...] - An ambiguous grammar may be more readable (since there are
> strictly
> more choices available), especially if you care more about the AST than
> the concrete syntax. [...]

IMHO it is exactly the other way around: I consider ambiguous grammars a
serious usability bug. Even if you hack around the ambiguities via meta
rules and/or technical tricks like "prefer shift" in (LA)LR parsers, you as
a poor human have to do the disambiguation for yourself. This makes it
*harder* to read code following the grammar, not easier. The BlockArguments
proposal introduced lots of additional ambiguities, and that's the reason
why I'm still opposed to it. I'm too lazy to dig out the old discussions,
but I gave a few examples where it was *highly* unclear/confusing what the
right parse should be with BlockArguments. This has been totally ignored,
and that ship has sailed...

In general, I consider it a very bad idea to give more and more strings a
meaning as a program: Some redundancy, like keywords and/or punctuation, is
highly useful as a human reader. Remember the old saying "A good language
should not make it easy to write correct programs, it should make it hard
to write incorrect ones", and BlockArguments was IMHO a step into the wrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210616/ec676938/attachment.html>

More information about the Haskell-Cafe mailing list