Suppose you want to use the integer whose denotation is
48930767
in various parts of your program. If you had to write out the denotation each time you wanted to use it, you would find that
INT special integer = 48930767
Now, whenever you want to use the integer, you write
special integer
in your program.
An identity declaration consists of four parts:
<mode indicant> <identifier> = <value>
You have already met the <mode indicant>
. An
identifier is a sequence
of one or more characters which starts with a lower-case letter and
continues with lower-case letters or digits or underscores. It can be
broken-up by spaces, newlines or tab characters. Here are some
examples of valid identifiers (they are separated by commas to show
you where they end, but the commas are not part of the
identifiers):
i, algol, rate 2 pay, eigen_value_3
The following are wrong:
2pairs escape.velocity XConfigureEvent
The first starts with a digit, the second contains a character which is neither a letter nor a digit nor an underscore, and the third contains capital letters.
An identifier looks like a name, in the ordinary sense of that word, but we do not use the term “name” in this sense because it has a special meaning in Algol 68 which will be explained in Chapter 5. The identifier can abut the mode indicant as in
INTa = 4
but this is unusual. For clarity in your programs, ensure that a mode indicant followed by an identifier is separated from the latter by a space.
The third part is the equals symbol =. The fourth part (the right-hand side of the equals symbol) requires a value. You will see later that the value can be any piece of program which yields a value of the mode specified by the mode indicant. So far, we have only met integers, and we can only denote positive integers.
There are two ways of declaring identifiers for two integers:
INT i = 2 ; INT j=3
The semicolon ; is called the go-on symbol because it means “throw away the value yielded by the previous phrase, and go on to the next phrase”. If this statement seems a little odd, just bear with it and all will become clear later. We can abbreviate the declarations as follows:
INT i=2, j = 3
The comma separates the two declarations, but does not mean that the i is declared first, followed by the j. On the contrary, it is up to the compiler to determine which declaration is elaborated first. They could even be done in parallel on a parallel processing computer. This is known as collateral elaboration, as opposed to sequential elaboration determined by the go-on symbol (the semicolon). We shall be meeting collateral elaboration again in later chapters. Elaboration means, roughly, execution or “working-out”. The compilation system translates your Algol 68 program into machine code. When the machine code is obeyed by the computer, your program is elaborated. The sequence of elaboration is determined by the compiler as well as by the structure of your program. Note that spaces are allowed almost everywhere in an Algol 68 program.
Some values are predefined in what is called the standard prelude. You will be learning more about it in succeeding chapters. One integer which is predefined in Algol 68 has the identifier max int. Can you guess its value?
INT
int
thirty-four
AreaOfSquare
INT thirty four > 33
INT big int = 3 000 000 000
max int
. AnsSian Mountbatten 2012-01-19