[fpc-devel] Semicolon before else

Juha Manninen juha.manninen at phnet.fi
Fri Jan 29 12:47:14 CET 2010


Hi.

Your explanation is correct but my approach is more pragmatic and less 
philosophical.
There are some cases already where you can use a semicolon or leave it out.
Like :

begin
  if a > 100 then
    DoThing1
  else if a > 50 then
    DoThing2
  else if a > 10 then
    DoThing3
  else
    DoThing4
end

You don't need a semicolon after the last DoThing4 because it is followed by 
END. That is handy when you need to change order and copy/paste those lines, 
and none of them has semicolon.
However :

begin
  if a > 100 then
    DoThing1
  else if a > 50 then
    DoThing2
  else if a > 10 then
    DoThing3
  else
    DoThing4;
  FinalAction;
end

Now you needed the semicolon.
Why not allow this, for pragmatic reasons:


begin
  if a > 100 then
    DoThing1;
  else if a > 50 then
    DoThing2;
  else if a > 10 then
    DoThing3;
  else
    DoThing4;
  FinalAction;
end

You can already add semicolons for example after END even they are not 
required.

This has the same spirit as Perl's array syntax which allows a comma also 
after the last item. It is handy when reordering or adding items. It may be 
wrong philosophically or technically (or something) but it works and makes 
things easier.
(This would be another improvement for Pascal const array syntax, too, but 
let's not go there now. It need its own thread.)


Regards,
Juha Manninen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20100129/41ba3e30/attachment.html>


More information about the fpc-devel mailing list