                       FIRST PRINCIPLES.
                       

 Turbo Pascal is a structured, typed language.  It is ALGOL-like, using a
 hierarchical structure (nesting) and free format.

 To appreciate these opening statements, a brief historical review of
 high-level languages is helpful.

   1957   FORTRAN        numerically orientated - fixed format.

   1960   ALGOL          numerically orientated - structured and typed.

   1965   BASIC          simple for teaching in schools and colleges.

   1971   Pascal         for teaching program concepts and allowing
                         efficient implementation of large programs.
                         ALGOL-like.

   1980   Ada            designed for US Dept. of Defense. Pascal-like.

   1983   Turbo Pascal   an enhanced version of Pascal.

 FORTRAN and BASIC have fixed format, such that each statement is located
 at a (fixed) point on a line after a line number, obligatory in BASIC,
 optional in FORTRAN.  ALGOL introduced free format, which allows the
 statements to be indented by varying amounts, so making programs more
 readable.

 ALGOL also introduced 'compound statements', such that several
 statements can form the body of a 'for loop' provided that they are
 surrounded in 'begin-end' brackets.

 ALGOL also uses a hierarchical structure (nesting), whereby compound
 statements can be executed repeatedly under the control of the 'for
 loop', which itself is embedded or nested within other statements.

 Whereas with FORTRAN and BASIC, 'if' statements require the use of GOTO,
 ALGOL eliminates the need for the GOTO-statement, by its implementation
 of compound statements.  The 'if-then-else' statement can be similarly
 accommodated and with suitable use of free format can produce a very
 readable program structure, as shown below.

   IF condition THEN
     BEGIN
        statement 1;
        ......
        statement m
     END
   ELSE
     BEGIN
        statement n;
        ......
        statement r
     END;


 To quote Edsger Dijkstra (1968), 'The difficulty in reading programs,
 which make much use of GOTO statements is a result of the "conceptual
 gap" between the static structure of the program (spread out on the
 page) and the dynamic structure of the corresponding computations
 (spread out in time)'.

 From this observation, the Structure Principle was defined as:

   'The static structure of the program should correspond in a simple way
   with the dynamic structure of the corresponding computations'.

 Whereas ALGOL introduced the concept of separate data types such as
 integer, real and Boolean, Pascal is even more strongly typed, including
 character, string and pointer types, etc.  Integer and real data types
 are further subdivided by size and range.  The purpose of data typing
 is to avoid errors and ambiguities at run-time, when for example 5.999
 should really be 6 for correct decision making within the program.

 It follows that all variables must be declared and typed at the start of
 the program.  In fact, all labels, constants, user-defined types and
 variables must be predeclared, together with any procedures and
 functions.  It is also important to initialize all variables, so as to
 ensure that spurious values are not acquired from the old contents of a
 memory location.

 In Pascal, variable names can be of any length and are chosen to be
 meaningful to the reader.  An assignment (i.e. giving a value to a memory
 location defined by a variable name) is indicated by := 

 With two exceptions, statements must be separated by a semi-colon (;),
 although one is not needed before END, but if included only implies a
 'null' statement.  The exceptions are that a semi-colon is not placed
 between END and ELSE in an IF-THEN-ELSE structure and the last END in the
 program or unit is followed by a period (.). 


 The text of the program is not 'case' sensitive, lower case being used in
 most instances.  In the examples above, capitals have been used on
 occasions to highlight 'reserved' words like BEGIN and END.

 All implementations of Pascal are based on 'Pascal User Manual and
 Report' 1975 by Kathleen Jensen and Prof. Niklaus Wirth, the Pascal
 originator.

               e.g.  UCSD    ISO    ANSI    Turbo

 Syntactic errors are found at compile time, semantic errors at run time
 and logical errors are detected in Turbo Pascal by using the 'watch'
 window and 'tracing', facilities which are available in the 'Integrated
 Development Environment', which is one of the most helpful features of
 Turbo Pascal.


 PRINCIPS.TXT
 1.3.90
