[fpc-devel] Semicolon before else

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Tue Jan 26 09:57:26 CET 2010

Aleksa Todorovic wrote:

> Agree. My primary intention was not to change official language, but
> to try to make a change which will help me in my work. I just shared
> it with others.

But in that case what's needed is not a simple change to this one case 
but an option to accept Modula-2 style syntax where you've got 
if...then...end; etc. hence eliminating the "dangling else" problem.

> Note that I fully understand how serious this change is. First, it
> moves away FPC from the land of Separator to the land of Terminators.
> Second, the grammar/parser is not LL(1) anymore (which is enough to
> reject this change in the first place). Third (as Daniel said), it
> requires change of compiler itself (else->otherwise). And so on, and
> so on...

There's also the issue that Turbo Pascal was very strict in rejecting ; 
before else in certain circumstances such as in a case statement: it was 
reported as a syntax error even if it could be parsed by other 
compilers. Enhancing the language is all very well, but anything which 
introduces a subtle incompatibility with one of the most popular Pascal 
implementations is probably not a good idea.

> So, if this patch is useful to someone, then it's great; else (if it's
> not), great again ;-)

But the more people who build up the skills to understand the compiler's 
internals the better :-)

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-devel mailing list