[fpc-devel] Semicolon before else

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Tue Jan 26 14:45:04 CET 2010


Marco van de Voort wrote:
> In our previous episode, Aleksa Todorovic said:
>>>> 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.
>>> Agree fully, that's how Wirth solved it, and I like it still best.
> 
>> Indeed, that would be far better solution. But, I wonder how many
>> people out there would be interested in having support for Modula2
>> syntax inside fpc...?
> 
> I don't think this is worth fixing in the Pascal modes at all. Sometimes
> compatibility simply weights more heavily.
> 
> But I've been dreaming of a M2 mode in FPC for quite some time. It would fit
> rather nicely.

I think a number of us are ex-M2 programmers :-) The one thing that does 
occur to me which could /possibly/ justify an extension of the parser is 
that the only structures in Delphi/FPC that insist on an extra begin-end 
around multiple statements are those that were in the original J&W 
Pascal. In particular the else...end in a case statement was added (by 
Turbo?) followed later by try...finally...end and try...except...end.

Being able to say that all control and data structures had a uniform 
format terminated by an end with neither a dangling-else problem nor 
ambiguities depending on whether somebody used ; as a separator or a 
terminator could be attractive.

-- 
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