To summarize what we have learned so far, the programs shown earlier all have the general form described in Figure 2.1:
END
.
BEGIN
signals the start of the sequence
of executable statements part of the program. The sequence of executable
statements consists of the program statements that are translated into
machine language and executed. The program statements seen so far consist of
statements that perform computations and input/output operations. These
executable statements are described in the next section.
END
pname;
where pname is the name of the program.
BEGIN
. Each statement is translated by the Ada compiler into one
or more machine-language instructions, which are copied to the object file and
later executed. Declarations, on the other hand, describe to the compiler the
meaning and purpose of each user-defined identifier. They result in the
allocation of some memory space to hold the data values.
Figure 2.1
WITH package1; WITH package2; ... WITH packageN; PROCEDURE pname IS declarations (variables, constants, etc.) BEGIN program statement; ... program statement; END pname;
PROGRAM STYLE
Use of Blank Space
PROCEDURE
and Distance
in
Program
2.5). Because extra blanks between words and symbols are ignored by the
compiler, you may insert them as desired to improve the style and appearance of
a program.
Always leave a blank space after a comma and before and after operators such
as *, -,
and =
.
Indent by two or more spaces all lines except for the first and last lines
of the program and the line BEGIN
.
Finally, use blank lines between sections of the program.
All of these measures are taken for the sole purpose of improving the style
and hence the clarity of the program. They have no effect whatever on the
meaning of the program as far as the computer is concerned; however, they make
it easier for people to read and understand the program. Be careful not to
insert blank spaces where they do not belong. For example, there cannot be a
space between the characters : and =
that comprise the assignment
symbol :=
. Also, you cannot put a blank in the middle of an
identifier.
Previous | Next | Table of Contents | Index | Program List | Copyright
Copyright © 1996 by Addison-Wesley Publishing Company, Inc.