[comp.lang.pascal] BEGINs and ENDs are superfluous

timcc@csv.viccol.edu.au (Tim Cook) (10/04/89)

In article <9253@pyr.gatech.EDU>, mlw@pyr.gatech.EDU (Michael Williams)
writes:
> ...
> In fact, I have the following preference:
> 
>     for i := 1 to 10 do begin
>        x := a[i];
>        b[i+1] := x + 10;
>     end;
> 
> The "begin" does not waste a line on my screen, allowing me to see more of
> my program.  The "end" lines up with the "if", "for", or "while" statements,
> allowing quick and easy alignments of scope.

Why not go all the way?  I believe that, if indentation is used properly,
the presence of BEGIN and END keywords is superfluous.  They are only there
so that the compiler knows where a block statement starts and ends.  The
programmer knows where the start and end of a block statement is by the
change in indentation.  Haven't we all wished at one time that the compiler
we were using was sensitive to indentation instead of BEGINs, ENDs, braces,
and semi-colons?

I would code the above example thus:

      FOR i := 1 TO 10 DO BEGIN
         x := a[i] ;
         b[i+1] := x + 10 END ;

The only BEGIN that I code on a line by itself is the one that starts the
code in a routine.

For a better idea:

      WHILE more DO BEGIN
         IF x < y THEN BEGIN
            more := false ;
            increment (x) ;
            REPEAT
               z := z - 10 ;
               writeln ('smaller') ;
               UNTIL z < 1000 END END ;
      writeln ('x = ', x:1) ;

A few other points:

   1.  The keywords CONST, TYPE, VAR and VALUE appear alone on a line
       because they need to be seen by the programmer as well as the
       compiler.

   2.  Semi-colons are also superfluous to the programmer's needs.  I read
       an article by some eminent computer scientist (I think) who
       demonstrated that with a few minor changes to the language, Pascal
       would not need semi-colons at all.  Anyway, they are statement
       separators, not terminators, and as such, should not be seen as part
       of any statement.  So, I separate them from the preceding statement
       by one space.

   3.  Enter anything that is fixed as uppercase, anything that you can
       modify as lowercase.  Only Pascal's keywords like PROGRAM, VAR,
       ARRAY, IF and WHILE are fixed.  Things like char, integer, writeln
       and others are predeclared identifiers.  They may be already there,
       but because they are identifiers, they can be modified (re-
       declared).  One exception to this in my case is VMS system and
       run-time-library definitions, which can be modified, but should only
       be modified by the VMS developers.  Anyway, DEC have a standard
       which says that system identifiers should always be represented in
       uppercase.  This policy allows me to see the syntax that has been
       dictated by Pascal, the elements of VMS, and the identifiers local
       to my program (those in lowercase that I know are not predeclared)
       with ease.

   4.  I also use the above policies to form my style of C indentation.

Another opinion for the bit-bucket :-)

--
Tim Cook          Systems Administrator, Victoria College Computer Services