On Wednesday, 31 March 2021 at 21:51:07 UTC, Arun wrote:
>Just curious. Does the compiler need semicolon anymore? Are there corner cases that don't work without semicolon?
SIL (in-house language @ Symmetry Investments, implemented in D) has optional semi-colons. We made them work by insisting that statements are unambiguous between eager and non-eager parsing over line-breaks. Instead of choosing which version is correct with a rule, we simply disallow anything that would be ambiguous.
For example:
a = foo
(bar())
Instead of deciding which interpretation is correct (assign the function foo
to a
then call bar
or call bar
, pass result to foo
, assign result of foo
to a
), this is simply a parse error and the user must include a backslash or a semicolon after foo
to disambiguate.
We are more conservative about this than we should be and therefore disallow some code that isn’t actually ambiguous, but in practice it doesn’t seem to be much of a problem.
Having said all that, D is fine with semicolons and should keep them.