Semicolons as separator/terminator

bron@SGI.COM (Bron Campbell Nelson)
Fri, 07 Sep 90 22:46:26 GMT

          From comp.compilers

Related articles
Semicolons as separator/terminator bron@SGI.COM (1990-09-07)
| List of all articles for this month |

Newsgroups: comp.compilers
From: bron@SGI.COM (Bron Campbell Nelson)
Organization: Compilers Central
Date: Fri, 07 Sep 90 22:46:26 GMT

Since everyone seems to be throwing their $0.02 coding tricks into
this discussion, I thought I'd toss in mine.

I never liked the semicolon as a separator, so I simply adopted a
coding style that allowed me to treat the semicolon as a terminator.
Every Pascal compiler I've ever worked with *allows* one to have null
statements (e.g. put a semicolon before an "end" statement). So by
simply always using begin/end blocks even for single statements (which
is probably a good idea in any event), you can just terminate each
statement with a semicolon. e.g.
while b1 do begin
You can even put a semicolon after the "begin" if you want, though I
never did. The only place you get into trouble is with the "else"
clause of an "if" statment, since you cannot have a semicolon
before an "else." So I just used:
if c1 then begin
end else begin
Admittedly, the "end else begin" part looks a bit funny, but is it
easy to get used to, and in my opinion looks less funny than putting
the semicolon in front of the statement (which other writers have
suggested). This also has the advantage that the same coding style
can be used in other languages (e.g. C), making it easier to switch
back and forth.

Bron Campbell Nelson or possibly ..!ames!sgi!bron

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.