[Lazarus] Semicolon checking
DougC
doug at moosemail.net
Mon Jan 16 13:29:10 CET 2017
I'm not going to kick you, Mark, as your comments are spot on.
What I think wold be very helpful to the FPC community is a warning that is issued when a semi-colon is immediately followed by a "begin" as that is an unusual construct and, as shown in the example here, an indicator of a likely mistake.
Doug C.
---- On Mon, 16 Jan 2017 03:27:25 -0500 Mark Morgan Lloyd via Lazarus <lazarus at lists.lazarus-ide.org> wrote ----
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]
--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170116/5098cba0/attachment.html>
More information about the Lazarus
mailing list