[Lazarus] Semicolon checking

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Mon Jan 16 09:27:25 CET 2017


On 16/01/17 07:30, Lars via Lazarus wrote:
> On Sun, January 15, 2017 3:30 pm, Vojtěch Čihák via Lazarus wrote:> Hello, has Lazarus (CodeTools) or FPC some checking for empty commands? I> accidentally did this stupid mistake:  > if ... then begin>>   end else;>   begin>     ...>     exit;>   end;>
> Yikes! I think you just discovered a bug in the pascal language itselfthat was not thought of... as when using a text editor it's easy to leavea semi colon laying around by accident some times.
> I wonder if Oberon solves this issue, or semi-colon-less languages haveany advantage.  If you remove the begin from a language (Wirth did in hislater languages) you get rid of some issues.-- _______________________________________________Lazarus mailing listLazarus at lists.lazarus-ide.orghttp://lists.lazarus-ide.org/listinfo/lazarus

It's one of a number of known nasties in the language definition. This 
is controversial, but Pascal was defined with ; being a /separator/ not 
a /terminator/, so strictly a semicolon is not needed before  end else 
until  etc. and in my experience only using it where necessary is a good 
habit to get into ( ;until was a syntax error in at least some versions 
of Turbo Pascal).

One other thing that helps in a very small way is to use 
case-otherwise-end rather than case-else-end, since it reduces the 
number of ambiguities.

Apart from that Wirth deserves no credit at all for leaving the 
dangling-else ambiguity in Pascal when it had been recognised and 
eliminated in ALGOL-68.

I expect to get kicked for all of the above. They are my opinions only, 
and might not be aligned with e.g. the coding style expected in patches 
submitted to the FPC or Lazarus projects.

-- 
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 Lazarus mailing list