Carnegie Institute of Technology ALGOL-20 ALGOL Language Manual
PDF
Документ
Реклама
Реклама
NOTICE WARNING CONCERNING COPYRIGHT RESTRICTIONS:
The copyright law of the United States (title 17, U.S. Code) governs the making
of photocopies or other reproductions of copyrighted material. Any copying of this
document without permission of its author may be prohibited by law.
A L G O L -20
A LANGUAGE
MANUAL
JANET W. FIERST, EDITOR
DAVID M. BLOCHER
ROBERT T. BRADEN
ARTHUR EVANS JR.
RICHARD B. GROVE
FIRST PRINTING FEBRUARY 1965
THIS WORK WAS SUPPORTED BY THE
ADVANCED RESEARCH PROJECTS AGENCY OF THE
OFFICE OF THE SECRETARY OF DEFENSE:
CONTRACT SD-146
CARNEGIE INSTITUTE OF TECHNOLOGY
MKT LIBRARY
CARNEHE-REUBN UNIVERSfJY
Acknowledgements
The construction of the programing system described here is
the result of the combined effort of many people. The following
were involved with coding the translator: David M. Blocher,
Arthur Evans, Jr., Janet W. Fierst, Richard B. Grove and Carol H.
Thompson. Ronald R. Bushyager, III, wrote WHAT, the assembly language
processor included in the translator. Charles L. Thornton wrote a
table loader (the "Meta-compiler") which is an essential part of the
process of assembling the translator. Grove wrote the relocator and
the librarian. Special thanks are owed to Robert T. Braden for acting
as the conscience of the group with many useful suggestions on "ALGOL
esthetics". The entire task was directed by Evans.
This document has been edited by Fierst, who also did much of the
writing. The following people, in addition, contributed to the writing
and editing of the document:
Blocher, Braden, Evans and Grove. Ronald
F. Hackleman wrote many of the relocatable library routine descriptions
appearing in Chapter 5. The typing has been done by Edythe Simmons, and
Robert D. Smith contributed materially with his editorial assistance.
PREFACE
ALGOL-20 is a realization of the international language
ALGOL-60. The international language, although a valuable vehicle
for the description of algorithms, does not really become useful
until it is implemented on computers. However, each implementer
has found it necessary in some cases and desirable in others to make
changes in the language. Further, additions to the language such
as input/output are necessary. This ALGOL-20 Manual is a description
of the realization of ALGOL as implemented at Carnegie Institute of
Technology.
Two additional documents are needed to complete the description
of Carnegie Tech ALGOL. One is a description of ALIBN - the librarian
used in connection with the two libraries. The other document describes
the assembly language - WHAT - which is built into the Algol translator.
The user may include assembly code as part of his program, as described
in the WHAT manual. These manuals are currently in preparation.
The internal operation of the translator has not been adequately
described. However, An ALGOL 60 Compiler, by A. Evans, which was
printed in Annual Review of Automatic Programming. Volume 4, Pergamon
Press, describes part of the translator. A preliminary version of the
format language used was described in A Format Language, by Alan J.
Perlis, in Comm. ACM, 7(Feb. 1964), pp. 89-96.
Arthur Evans, Jr.
January, 1965
r
Introduction
<
The manual is organized as follows: Chapter 0 is a ready
reference containing in summary form the information the experienced
programmer will need.
It is not suitable for reading by itself,
but is useful for reference to particular points. Chapter 1 is an
introduction which includes bibliographical citations to several
introductory texts on ALGOL, for the programmer who does not yet
know the language. Chapter 2 describes in considerable detail how
the local system differs from the international language. Chapter 3
contains a detailed description of the input/output system provided
at Carnegie Tech. A format language of some sophistication is defined.
Chapter 4 contains a description of system statements - those statements used to communicate to the translator information which is not
part of the ALGOL language. Chapter 5 contains a description of the
two libraries available to the translator and contains descriptions of
the routines currently in the libraries. Chapter 6 is a collection of
miscellaneous topics, including keypunch conventions, error codes, etc.
,
Chapter 7 includes the ALGOL-60 report as revised in 1962 and a
^
summarized list of differences between ALGOL-60 and local ALGOL.
Page numbers are of the form AL.m.n, where m indicates the chapter
number and n is the page in the chapter. Two chapters —
three and
six — are divided into sub-chapters distinguished by lower case
letters, e.g., Chapter 3b. The sub-chapters are also paged individually
so that the first page of Chapter 3b is AL.3b.l, immediately following
AL.3a.2.
s
CONTENTS
ALGOL Ready Reference
0.1 - 0.16
1
Introduction
1.1 - 1.2
2
Notes on ALGOL at Carnegie Tech
2.1 - 2.14
3
ALGOL-20 Input/Output
3.1 - 3
CHAPTER 0
a. Introduction
b. Primer on PRINT
c. Primer on READ
d. Complete Description of All
I/O Commands
"
n
J
4.
System Statements
4.1 - 4.6
5.
The ALGOL Library
5.1 - 5.3
6.
a. Introduction
b. Routines in the Library
Miscellaneous
a. ALGOL-20 Card Format and
Keypunching Conventions
b. ALGOL-20 Error Messages
c. Printing of the Compiled Program
d. Privileged Identifiers
e, Machine-Dependent Features
Octal Constants
String Constants
Logic Variables
Half Variables
Index Variables
Segments
Disc/Tape Routines
h, Storage Allocation
r
7.
6a. 1
6a.2
6b. 1
6c. 1
6d.l
6e.l
6b.7
6d.4
6e.4
6f .1
6h.l - 6h.2
ALGOL-60
a.
b.
c.
The Revised ALGOL-60 Report
Features of ALGOL-60 Which are
Changed in ALGOL-20
Restrictions on ALGOL-20 to
Transform it into a Subset
of ALGOL-60
7a.1 - 7a.17
7b.1 - 7b.2
7c.1 - 7c.2
r-
Chapter 0 - ALGOL READY REFERENCE
ALGOL Notes and Error Messages
2
Compile Errors
2
Notes
5
Run Errors
5
Keypunching
6
Precedence Rules for Operators and Relations
6
Format Instructions
7
Control Instructions
7
Instructions for PRINT and PUNCH
7
Instructions for READ
9
Library Routines and Standard Functions
11
Relocatable Routines
11
Symbolic Routines
11
Standard Functions
12
Reserved Identifiers
13
Privileged Identifiers
13
ALGOL READY REFERENCE
ALGOL Notes and Error Messages
(Chapter 6b)
Compile Errors
Phase I Errors
0:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
(Each of these errors terminates Phase II.)
The program does not start with begin.
A statement starts with an illegal character or an illegal reserved word.
A statement starts with an identifier followed by an illegal character.
In an expression an operand was expected and was not found.
In an expression a binary operator was expected and was not found.
(Possibly caused by a semicolon missing after the preceding statement.)
A "J" does not have a matching '»[".
An array element has been used illegally.
A ":" has appeared incorrectly.
A V
or
has appeared incorrectly.
A " ) " does not have a matching "(".
A "," has appeared incorrectly.
then has appeared without if.
else has appeared without then.
Characters are still in the stack after a
or an end.
A procedure statement is followed by other than end, else, or ";".
for is not followed by an identifier.
The for variable is not followed by a V or
step has appeared without for.
until has appeared without step.
while has appeared without for.
do has appeared without for.
go to is not followed by an identifier or " ( " or if.
go to if...then...is not followed by else.
An obscure error in a go to statement.
An impossible error after begin. ("J-" is not the second element in the
stack. See Error 98.)
own is followed by something other than <type>.
An" array declaration does not specify subscript bounds.
The identifier list of a declaration is not followed by a V * .
switch is not followed by an identifier.
The identifier of a switch declaration Is not followed by a ' V or
procedure is not followed by an identifier.
A procedure identifier is not followed by " ( " or
A formal parameter list is not followed by " ) " .
The " ) " following a parameter list is not followed by a
The identifier list in a specification is not followed by a
An identifier did not follow the "," in an Identifier list.
The illegal construction "then if" has occurredA switch with more than one subscript position has been used.
The value part of a procedure declaration was not followed by a
ALGOL READY REFERENCE
41:
42:
43:
44:
45:
46:
47:
48:
49:
The name of a permanent subroutine (such as "SIN") is not followed by " ( " .
There is an extra "," or else a missing ":" in an array declaration.
More begin's than end'a have occurred when the end-of-file Is reached.
Impossible - see Error 98.
max or min is not followed by " ( " .
In an array declaration the identifier list is not followed by " [ " .
Array specifier has subscript bounds, which it should not.
library is not followed by <type> or procedure.
Phase I Errors
50:
51:
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
A reserved input/output word is not followed by " ( " .
A format list element starts with an illegal character, (Should be "<"
or "-*" or "$" or identifier).
"-»" is missing: i.e., a replicator was expected but not found.
for is missing after "$".
'U" is not followed by "$" or an identifier.
" ) " or ">" is not followed by " ) " or ",".
A name statement or format statement is not followed by end, else or ••. it
A replicator is not followed by "(" or "<".
"<" or "," is followed by an illegal character.
An integer is followed by an illegal character.
A format instruction is not followed by
or ",".
An illegal prefix to a numeric primary has been used.
An illegal numeric primary has been used.
appears in a numeric primary in a read statement.
In a numeric primary, E, F or S is not followed by an integer.
Phase II Errors
*70:
71:
72:
73:
74:
75:
76:
78
(format and name statements). (Each of these errors terminates
Phase II.)
(Only those errors marked "*" turn off Phase II.)
A reserved word which is not yet available has been used.
A label has been used but not defined. (The name of the label is
printed prior to this error message)
An identifier has been used but not declared.
An identifier has been declared twice in this block.
An identifier in the value list is not a parameter.
An identifier which has been used as a procedure has not been declared to
be one.
A subscripted identifier has not been declared to be an array or switch.
The program is too long.
A procedure identifier which is not a function designator has been used
in an expression.
ALGOL READY REFERENCE
79:
80:
81:
82:
83:
84:
85:
86:
*87:
88:
89:
*90:
*91:
92:
93:
94:
95:
An identifier which has been used as a switch has not been declared to
be one.
An array identifier has been used without subscripts.
Too many index variables have been declared.
A label or array or switch has been called by value.
An identifier in a specification list is not a parameter.
In a procedure declaration a parameter is not specified.
In a procedure declaration a parameter is specified twice.
A procedure, switch or label appears on the left of a
or ' V .
The W2 stack is too full.
More than 100 relocatable library procedures have been declared.
A constant has been used In place of an identifier, e.g., 33 [k] .
A subscripted for variable has been used (this is not yet available in
ALGOL-20).
The next-command pointer is less than the base of the program.
Miscellaneous Errors
96:
97:
98:
99:
A possible translator error - bring listing to Janet Fierst at the
Computation Center.
Impossible: bring your listing to A. Evans at the Computation Center.
Same as 98.
Subscan Errors
100:
101:
102
103
104
105
106
107
108
*109
110
111
112
113
114
A card column contains an illegal combination of punches.
Too many abcons or adcons have been used (numerical constants and
alphanumeric string constants).
Too many decimal points appear in a number.
Too many 'V's appear in a number.
An error has appeared in a parameter delimiter comment: ")<any string
not containing:>:(".
An illegal bar ( "I" ) variable has been used.
A constant has been used which is too large to fit into a real variable.
A V
is followed by something other than "+", —or-<dlgit>.
A string goes over the end of a card.
The symbol table has been exceeded.
,,
M
ALGOL READY REFERENCE
System Statement Errors
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
An abcon system statement has occurred after code has been complied.
An abcon system statement has requested more space than there is in
user memory.
An illegal SY card has occurred. (This may be caused by a LIBRARY card
after the symbolic library has been released.)
The library procedure nesting exceeds 5.
WHAT has been called after It has been released.
An illegal segment statement has been used.
An SY LIBRARY card has asked for a routine not in the symbolic library.
A library procedure declaration has named a routine not in the relocatat
library.
Notes
Note 1:
Note 2:
Note 3:
Note 4:
Note 5:
Note 6:
Note 7:
Note 8:
Note 9:
end comment convention was used on preceding card. That is, everything was ignored up to V \ end. or else.
A function designator has been used as a procedure statement.
In an arithmetic or boolean expression, the construction If...then if
has occurred. This is syntactically illegal but unambiguous,"^ is"
therefore accepted by the translator.
An arithmetic (boolean) (designational) expression has been used
where a simple arithmetic (boolean) (designational) expression
should have been used.
In a designational expression, the construction if...then if has
occurred? This is syntactically illegal but un^bigu^u7."~
Phase II has been turned off.
The construction if...then for...do...else... which is legal in
ALGOL 60 but ill^al in~ALG0L 62"has beln" used.
TAB appears as a character.
Fifty errors have been found on a single card; compilation has been
terminated.
Run Errors
ADRP
CFLG
EXP
EXPO
LN
RAD1
RAD2
READ
address—opcode fault
command flag error
EXP (x) called with- X > 160.116998
exponent overflow
LN (x) called with X <: 0
upper < lower in a bound pair in an array declaration
declared arrays exceed available space
an error has occurred in jading a data card
AL.0.6
ALGOL READY REFERENCE
SIN
SQRT
TIMR
XtAl
XfA2
Xt A3
the argument to SIN or COS Is greater than 8t2l.
SQRT (X) called with X < 0
time limit exceeded
X = 0 and A £ 0
A * LN (X) > 160.116998
X £ 0 and A not integer valued
Keypunching
(Chapter 6a)
column -
111 1 1 111 11 2,'.222 2222223333333333...R
12 3 45678 9012 3 4 567 89 0 123 4567890123456789
M
WHAT
WH
ALG0I
AL
ALGOL text
system
SY.
system text
comment
CO
comment
.LOC.
RM is the right margin.
F
OP.
M
Addr,Index;comment..
(Initially RM = 72. It may be changed by
SY RIGHT MARGIN - see Chapter 4.)
Precedence rules for operators and relations
;
(performed first)
MOD
t
+ - (unary)
* /
+ - (binary)
(performed last)
(Chapter 2)
ALGOL READY REFERENCE
Format Instructions
(Chapter 3)
Control Instructions
nC
Sets CP to column n (CP «- n) .
nR
Moves CP n columns to the right (CP
CP + n)
nL
Moves CP n columns to the left (CP
CP - n) .
Instructions for PRINT and PUNCH
Control and Alphanumerics
nE
Prints or punches the contents of the appropriate
buffer, clears the buffer to blanks, prints or
punches n-1 blank lines, and sets CP to left margin.
nW
Prints or punches the contents of the appropriate
buffer n times. CP and the buffer are not changed.
Upspaces the paper to a new page and prints a page
header on the first line. CP and the buffer are
not changed.
*<string>'
This instruction is ignored in PUNCH.
Stores the characters of the string into the appropriate buffer.
nB
Stores n blanks.
nQ
Stores n quotes (.') .
nA
Stores n characters which are taken from i ((n+3)/4)
names.
nT
Stores min (5, n) characters which are taken from
one of the internal strings 'TRUE ', 'FALSE* or
'UNDEF*, according to the boolean value of the
corresponding name.
Numeric Instructions
1.
Prefix
L$
Stores a dollar sign left-justified.
$
Stores a dollar sign immediately before the first
digit.
L+(L-)
Stores the sign (sign if minus) left-justified or
immediately after a '$' stored by "L$".
ALGOL READY REFERENCE
+ (-)
Stores the sign (sign if minus) immediately before
the first digit or a '$' stored by "$".
If the
number is negative, a minus sign is stored;
if
the number is non-negative, a plus sign (blank) is
stored.
2.
Numeric Primary
nD
Stores n digits or blanks. Leading (or trailing)
zeros are replaced by blanks.
nZ
Stores n digits.
Stores a decimal point, '.'
3.
Suffix
L
Shifts the number until the left-most digit is nonzero (if possible) and stores the resultant
exponent.
E(F)+n
Shifts the number until its exponent equals + n.
The resultant exponent is (is not) printed.
S+n
Shifts the number until the left-most digit is
non-zero (if possible).
The decimal point is
inserted in the position to give an exponent equal
to +n and the exponent is stored. The numeric primary must be of the form "mD. or "mZ.".
n
H
Converts and stores the number in octal (base 8)
instead of decimal.
K
Invokes special spacing.
If the prefix contains
"L$" or "$", the digits of the number are stored
in groups of three separated by commas.
If neither
"L$" nor "$'• appears, the digits are stored in
groups of five, separated by blanks.
N
Suppresses error printing which may occur when
left-most non-zero digits overflow the field specified by the numeric primary.
T
Truncates the number at the last digit stored.
Normally, numbers are rounded by adding five to the
first digit not printed.
ALGOL READY REFERENCE
Instructions for READ
Control and Alphanumeric Instructions
nE
Reads n card images into the READ buffer and sets
CP to left margin. Only the last card image read
is available after the instruction is executed.
nW
Functions as "nE" except that the card images are
also listed on the printer.
•<string>'
Causes the n characters of the string to be
stored, four per word, into the next
names.
i((n+3)/4)
If n is not a multiple of four, characters
in the last name are stored right-justified. The
CP and buffer are not changed.
nA
Scans the characters in the next n positions of the
buffer and stores them as in the ^string^ instruction.
nT
Scans the characters in the next n positions of the
buffer.
If the first non-blank character is the
letter "T", the value true is stored in the next
name; otherwise, the value of the name is set to
false. The corresponding name must be of type
boolean or logic.
Numeric Instructions
1. Numeric Primary
nD
Scans the number represented in the next n positions
of the buffer.
Blanks are ignored. Numbers are in
free field format and may contain signs, decimal
points, and exponents. Numbers preceded by a
are treated as octal quantities.
nZ
Scans as "nD" except that blanks are treated as
zeros.
Suffix
H
Assumes the number read to be octal (base 8)
instead of decimal.
AL.0.10
ALGOL READY REFERENCE
E+n
Multiplies the number read by ten (eight) raised
to the power +n.
N
Causes illegal characters (such as letters) to be
ignored.
3.
Free Read
nF
Scans and concatenates n octal or decimal numbers
in fields separated by commas. Blanks are ignored
with the exception that if an entire field is blank,
the corresponding name is unchanged.
ceded by a 'V"
Numbers pre-
are treated as octal. A number field
may be continued over the end of a card image. The
last number in the data group must be followed by
either a " " or a "*".
(
(
AL.Q.li
ALGOL READY REFERENCE
(Chapter 5)
Relocatable Routines (i.e., library procedures)
AND.CALL
sets the scratch pointer and enters AND
AND.FILE
assigns a logical file type to an AND file
DISC.READ
reads from disc or tape
DISC.WRITE
writes on disc or tape
GOOF.STAR
prints a run-error message
GO.SEG
slews to a segment
LINK
links to a segment
RUN.ERROR
sets up run-error recovery
SLEW
slews to a record
SYSTEM.DUMP
Symbolic Routines
dumps an ALGOL program as a system
AND.PUNCH
BANSOLV
punches an AND record onto cards
solves a system of linear equations whose coefficient
COMDIV
matrix is a band matrix
CURVEFIT
computes the quotient of two complex numbers
determines the best least squares polynomial approxi-
CURF1T
mation to a given curve, with or without constraints
determines the best least squares polynomial approxi-
ELIPS
mation to a given curve, with constraints
computes the values of the complete elliptic integrals
FREQ
of the first and second kinds
determines the frequency distribution of a given set
GAME
of data
GJR
solves a finite, zero-sum, two-person game
HERMJA
JACOBI
MULLER
computes the inverse of a given matrix
finds all the eigenvectors and eigenvalues of a given
Hermitian matrix
finds all eigenvectors and eigenvalues of a given
symmetric matrix
finds the real and complex roots of a general equation
of the form
f(z) = 0
ALGOL READY REFERENCE
NEVILLE
c
computes approximate values of a tabulated function
by interpolation
NORMRAN
computes a sequence of normally distributed pseudorandom numbers
PLOT
produces the graph of one to ten functions
RANDOM
computes a sequence of uniformly distributed pseudorandom numbers
SIM
performs numerical Integration by Simpson's method
SORT1
sorts a l i B t of numbers into ascending order
Standard Functions
(i.e.. built-in functions)
ABS
absolute value
ARCTAN
arctangent
BUFFERSET
redefines the input/output buffers
CLOCK
time since the last job-card minus parameter (in seconds)
COS
cosine
DEBUGPRINT
a fixed format print routine
ENTIER
the largest integer which is not greater than the
parameter
EXP
exponential
(e*)
HALT
halt
LN
natural logarithm
MAX
maximum "
I
(see page AL.2.10 in the ALGOL manual)
MIN
minimum J
PAGES
number of pages since the jobcard
PAUSE
saves the program for restart
PRINT
controls printing
SIGN
-1 if parameter negative, +1 if positive, 0 if zero
SIN
sine
SQRT
TIME
square root
time since midnight (in seconds)
MOD is an operator such that for integer m and n the quantity m MOD n is the
remainder on dividing m by n.
c
r
ALGOL READY REFERENCE
Reserved Identifiers
ABS
ARCTAN
ARRAY
BEGIN
BOOLEAN
COMMENT
COS
DO
ELSE
END
ENTIER
EXP
FALSE
FOR
FORWARD
GO
GOTO
(1)
(2)
(2)
(1)
(I)
(1)
(1)
(2)
U)
(I)
CD
(2)
(2)
(1)
(1)
(3-NA)
(1)
(1)
(Chapter 2)
GO TO
HALF
IF
INDEX
INPUT
INTEGER
LABEL
LIBRARY
LN
LOGIC
MAX
MIN
MOD
MONITOR
NAME
OUTPUT
OWN
(1)
(3-2.5)
(1)
(3-2.5)
(3-NA)
(1)
(1, 3-2.10)
(3-5. Iff)
(2)
(3-2.5)
(3-2.9)
(3-2.9)
(3lNA)
(3-3.Iff)
(3-NA)
(1)
9)
PRINT
PROCEDURE
PUNCH
READ
REAL
SIGN
SIN
SQRT
STEP
STRING
SWITCH
THEN
TRUE
UNTIL
VALUE
WHILE
(3-3.Iff)
(1)
(3-3.Iff)
(3-3.Iff)
(1)
(2!
(2!
(2!
ALGOL 60 "built in" word.
(2) ALGOL 60 reserved function identifier.
(3) ALGOL 20 reserved word—see page reference.
Privileged Identifiers
(NA means not now available.)
(Chapter 6d)
ACC
real
Accumulator
CLOCK
integer procedure
(time in seconds since job-card) minus parameter
DAY
logic
•uddu'
DEBUGPRINT
procedure
fixed format print routine
EPSILON
real
smallest positive number « 8T-63
HALT
procedure
halt
INFINITY
real
largest positive number » (8t14-1)*8t63
MONTH
logic
'mmrau' mmm = name of month
PAGES
integer procedure
number of pages since job-card
PAUSE
procedure
save for restart
PRINT
procedure
controls printing on teletype
TIME
integer procedure
time in seconds since midnight
YEAR
logic
•yy^J
dd = day of month
yy = last two digits of year
bwt
mm
AL.0.14
labels In WHAT and ALIBN
Complement 0 when accessed arithmetically
1 flag
2 flag
-i
3 flag
Function variable for relocatable library procedures
INFINITY = (8!14-1) * 8t13 (Chapter 6d)
-i
EPSILON = 8t(-63) (Chapter 6d)
Dynamic block level - pointer to array stack (an index register)
i
—>
i20
1
-i
i4
3
-,576
—I
c
-» a
i
9
Exit from FORMAT and NAME
i
1
0
Current NAME list
—ill
Current FORMAT list
i
1
2
NAME routine
—i 1
3
PRINT routine
-i 1
4
PUNCH routine
-i 1
5
READ routine
-i 1
routine
i186
17 FORMAT
Page-and-print-page-header routine
-i 0
19 go to <label> routine
-i 2
run-time array declaration routine
~i2221 RAD
begin administration routine
end administration routine
-i
2
3
procedure begin administration routine
i
2
4
procedure end administration routine
i
2
5
GOOF*
: Run Error routine
i
2
6
ADDR-OP
routine
.
2
7
LINK
routine
i9
28
-i 2
Last location of user memory + 1
-i 3
0
Contains base of compiled code
.
3
1 Contains end of relocated subroutines
.
3
2
Contains maximum location used by scalars
i
3
3
Base of array stack
-i 3
4
Contains compile-time block level of current procedure
i 36
5 Contains run-time block level of current procedure
-i 3
Base of run-time procedure nesting stack
-i 3
7
Run-error recovery cell
i9
38 Contains segment number
-i 3
Contains physical right margin for READ
-i 4
0
Contains physical right margin for PRINT
i
4
0
+
1
Contains physical right margin for PUNCH
i
4
0
+
2
switch for end
-i4241 RUN.ERROR
Run-time error printinj'mode switch (Chapter 5.RUNERROR)
i
4
3
i
4
4
-i 45
c
c
AL.0.15
1 variables in ALGOL
READ character pointer for standard buffer
1200
120L
1202
1203
1204
1205
1206
READ right margin for standard buffer
]207
PRINT and PUNCH left margin for standard buffer
1208
1209
1210
Format switch
|211
NAME switch
1212
1213
1214
1215
1250
Page counter
j 251
1252
READ left margin for standard buffer
PRINT and PUNCH character pointer for standard buffer
PRINT and PUNCH right margin for standard buffer
Page header switch
Up-space counter
Left-justify switch
Current READ buffer
Current PRINT buffer
Current PUNCH buffer
AL.0.16
System Statements (Chapter 4)
Print Control for Compilation Listing
PAGE
Eject printer paper to top of next page.
LINE n
Skip n lines.
SINGLE
Single space the listing.
DOUBLE
Double space the listing.
INDENT n or INDENT + n
Set the left margin of the listing to n
or K+n.
$ PRINT <parameter string>
Print or don't print selected parts of
the listing.
Miscellaneous
RIGHT MARGIN n
Scan cards to column n for text.
LIBRARY <identifier>
Fetch <identifier> from the symbolic
library.
Reserve space for n abcons and n abcons.
t n ABCONS
SEGMENT n., n_
JL
Z
Treat this program as segment n of
l
length n .
2
RELEASE WHAT
RELEASE SYMBOLIC LIBRARY
DEBUG n
WHAT will no longer be used.
Free the
space fox compilation.
The symbolic library will no longer be
used. Free the space for compilation.
If n > 0 print the results produced by the
three phases of the translator.
do not print the results.
* not printed
$ may not contain comments
+ must occur before the first begin
If n=0
AL.1.1
^
CHAPTER I
INTRODUCTION TO ALGOL
ALGOL is an international algorithmic programming language designed
for problems whose solution can be expressed in algebraic notation.
It is
international in that its specifications have been agreed upon by an
international committee and it has received wide acceptance throughout the
world.
It is algorithmic in that it is designed for the natural representa-
tion of algorithms.
It permits the programmer to write his code in such a
way that it is highly readable with an obvious flow of control. The existence of an ever-growing body of published algorithms increases the utility
of the language to the user.
The ALGOL language as it exists at Carnegie Tech contains essentially
all the features which have been specified for the international language,
the only major exception being recursive procedures. Thus the user of
ALGOL at Carnegie Tech is using a language with worldwide acceptance and
understanding.
^
Our local version has been augmented by certain features
not now available in the international language, the most notable of which
is an extensive input/output facility.
It is not the purpose of this document to provide the user who is
unfamiliar with ALGOL with an introduction to that language, since the literature now includes several very fine works which perform this function
admirably.
For the user who is learning programming at the same time that
he is learning ALGOL, McCracken's Guide to ALGOL Programming is an easy
introduction.
(See the bibliography at the end of this chapter for a
complete citation.)
It is used as the text for the introductory program-
ming course at Carnegie Tech.
Chapter II of the present work contains a
detailed listing of the ways in which the ALGOL system at Carnegie Tech
differs from ALGOL as described by McCracken, including references to
section
numbers in McCracken's text.
Unfortunately, McCracken does not
give an adequate discussion of ALGOL procedures or of the structure and
syntax of conditional statements and expressions.
AL.1.2
(
Bottenbruch's tutorial article in the ACM Journal is a complete introduction, and features good discussions of ALGOL procedures with explanations
and examples and of conditional statements and expressions.
For the more experienced programmer who wishes to learn ALGOL, Christian
Anderson's text will be worthwhile.
Anderson provides a readable introduction
to what is important in ALGOL-60.
Another introduction which might be considered is that of E. W. Dijkstra.
This is a very complete book describing all of ALGOL.
It contains some com-
mentary which is not elsewhere available on the effects of the limited range
of number representation in computers.
It also contains a good discussion
of ALGOL esoterica including Sneaky Procedures.
The basic document which defines the ALGOL language is the Revised
Report on the Algorithmic Language ALGOL-60 edited by Peter Naur. This report
defines the language completely and unambiguously.
It is, however, not easy
reading and it is not recommended to the beginner in ALGOL.
It is reproduced
as Chapter 7 of this report.
r
^
Bibliography
Anderson, C , An Introduction to ALGOL 60, Addison Wesley Publishing Co, Inc.,
Reading, Mass.
Bottenbruch, H,, Structure and Use of ALGOL 60. Journal of the ACM, 9, No. 2
(1962), 161-221.
Dijkstra, E. W., A Primer of ALGOL 60 Programming, Academic Press, London,
<
England.
McCracken, D. D., A Guide to ALGOL Programming. John Wiley and Sons, Inc.,
New York.
Naur, P., editor. Revised Report on the Algorithmic Language ALGOL 60.
Communications of the ACM, 6, No. 1 (1963), 1-17.
c
r
AL.2.1
CHAPTER 2
r
Notes on ALGOL at Carnegie Tech
INTRODUCTION
ALGOL-60 has been designed to be both a universal language for describing
and publishing numerical algorithms, and a programming language for executing
algorithms on computing machines. The "reference language" ALGOL-60 has been
precisely and elegantly defined in the Revised ALGOL-60 Report (Communications
of the ACM, 6, 1 (Jan. 1963)), When ALGOL is actually implemented on a particular computer, however, some changes of notation and some restrictions are
usually added to this definition.
The ALGOL translator which has been written at Carnegie Tech for the
CDC G-20 computer accepts a language which we call ALGOL-20 to distinguish it
from ALGOL-60 when we need to be purists. As a matter of fact, most of the
differences between ALGOL-20 and the reference language ALGOL-60 are minor;
however, a knowledge of them is needed to use the CIT ALGOL system successfully.
In this document, a reference to simply "ALGOL" will always mean ALGOL-60, the
'
reference language.
This chapter describes those aspects of ALGOL-20 which differ from
ALGOL-60.
As such, it is the primary documentation of our ALGOL system.
It
is keyed to both the Revised ALGOL-60 report and to the text, A Guide to Algol,
by D. D. McCracken.
References to the former are by section numbers given in
square brackets, and to the latter by section numbers given in round brackets.
Thus the paragraph at the top of the next page relates to section 2.3 of the
Revised Algol Report and to section 1.4 of McCracken.
AL.2.2
SYMBOLS
(1.4) [2.3]
The G-20 accepts all of the special symbols of ALGOL-60 except for those
shown in the following table:
ALGOL-20
•3
("implies")
Not available, but "-," may be used with " v " to
obtain the same effect. See page 2.8.
III
ALGOL-60
("is equivalent")
Use
X
(multiplication)
Use "*".
See page 2.8.
Not available, but "1"may be used with
with the same effect. See page 2.7.
"/"
Use *<-»>".
Use "-.<".
6>
(string quotes)
Both represented by '.
See page 2.3.
In four cases, ALGOL-20 uses a pair of adjacent symbols to stand for a
single symbol of ALGOL-60. For example, the ALGOL-60 assignment operator ": = "
is strictly a single symbol, but it must be punched into an ALGOL-20 program
card as a colon and an equal sign in adjacent columns. There must be no blanks
separating the symbols of the pair, and they must both be on the same card.
Note:
punching them into the same column will give a "hash" of holes which the
G-20 will Interpret as some other (erroneous) character. The four doublesymbol characters are
ALGOL-60 character
I ALGOL-20 character pair
(V»
non-existant
non-existant
non-existant
8R
8L
8F
is also allowed)
AL.2.3
NUMBERS
^
(a)
(2.1) [2.5]
A number, N, In an ALGOL-20 program must either be zero (which may be
punched with or without a decimal point) or else its absolute value N must
satisfy:
1.275^-57 *
(b)
N 5
3.450, +69
o
Because of the nature of the G-20 computer, the distinction between
real and integer numbers is unimportant. The programmer may write an integervalued constant with or without a decimal point (e.g., "34", "34.", or "34.0")
without changing the type of arithmetic performed with the constant.
Numbers are represented in the G-20 in "floating point" form with a maximum of 42 binary digits of mantissa, corresponding to approximately 12 decimal
digits of precision.
If more than 12 digits are written, the extra (least
significant) digits will be ignored.
(The number is rounded at the 14th octal
digit.)
(c)
In ALGOL-20, the last character of a real number may. be a decimal
point; thus, the number "6." is legal.
(d) Octal numbers may be written in ALGOL-20. See Chapter 6e.
^
STRINGS
[2.6]
(a) A string cannot contain a string since ALGOL-20 has no way of distinguishing between the left and right string quotes.
(b) Strings of four characters or less may be used as logic constants
and assigned to logic variables.
If more than four letters appear in such a
string, only the leftmost four are used.
Strings of less than four characters
are stored right-justified.
IDENTIFIERS AND VARIABLES
(2.2) [2.3, 3 . l]
(a) Only upper case (capital) letters are available in ALGOL-20.
(b)
In ALGOL-20, certain identifiers have special meanings and are
therefore reserved.
The programmer may never use these reserved ALGOL identi-
fiers as variables or, indeed, for any purpose other than their reserved meanings.
These reserved identifiers must be separated from adjacent identifiers
by at least one blank.
For example, if the blank between the reserved
identifier _IF and the identifier "X" were omitted in "IF X > 0", then the
ALGOL translator would interpret "IFX" as a single variable identifier; as
a result, the statement would have no meaning at all.
The reserved identifiers in ALGOL-20 are
ABS
ARCTAN
ARRAY
BEGIN
BOOLEAN
COMMENT
COS
DO
ELSE
END
ENTIER
EXP
FALSE
FOR
FORWARD
GO
GOTO
GO TO
HALF
IF
INDEX
INPUT
INTEGER
LABEL
LIBRARY
LN
LOGIC
MAX
MIN
MOD
MONITOR
NAME
OUTPUT
OWN
PRINT
PROCEDURE
PUNCH
READ
REAL
SIGN
SIN
SQRT
STEP
STRING
SWITCH
THEN
TRUE
UNTIL
VALUE
WHILE
Sqme of these reserved identifiers have no ALGOL-60 equivalent; In particular;
HALF, INDEX, LOGIC (see page 2.5 below)
MAX, MIN, MOD (see page 2.9 below)
NAME, INPUT, OUTPUT, PRINT, PUNCH, READ
(see Chapter 3 - Input/Output)
LIBRARY (see Chapter 5)
FORWARD
MONITOR
FORWARD and MONITOR have not yet been implemented, but will be described
when they are available.
All of the ALGOL-60 standard functions are available in ALGOL-20, and
their names are reserved identifiers:
ABS
ENTIER
SIGN
(2.4)
ARCTAN
EXP
SIN
[3.1.4]
COS
LN
SQRT
See Chapter 5 for further information on these functions.
"TO" is reserved only when it follows immediately after the reserved
identifier GO.
In any other context, "TO" may be used as an ordinary
f**
identifier
In
of
by t h e
addition
"privileged"
declared;
outside
does
they
of
may s i m p l y
would
end of
identifiers
to
in effect,
the
the
the
inner
inner
are
additional
(c)
Spa-es
grammer may,
separate
periods
block,
instances
at
is
These
6d.
cannot
i n t o words
and
in
if
same
and d e c l a r e
privileged
identifiers
time.
the
privileged
listed
accidentally
they
are
he
it
as
identifier
the
their
to t h i s
not
interfere
he
is
soon as
and
may b e a d d e d
Since
programmer
use
meaning as
are
head
meaning,
and
a privileged
sprinkle
improve
an
identifier
periods
the
i.)
in
list
reserved,
with
ALGOL-20.
within
readability
b y ti.-> ALGOL-20 t r a n s l a t o r ;
the
its
set
being
a block
if
a
identi-
ALGOL p r o g r a m .
appear within
freely
in
Therefore,
Identifiers
some f u t u r e
ALGOL-20 i n c l u d e s
translator
privileged
its
notes.
meanings without
the program.
resumes
passed.
above,
by t h e
Further,
in Chapter
may n o t
of
it
a current
ignored
it
identifiers
howorer,
them
are
is
Center
privileged
into
that
these
built-in
identifiers
identifier.
explained
written
these
of
listed
declared
b l o c k of
fact
block
Computation
words
which have
u s e one of
ignore
See page 2.10
reserved
outer-most
i n an
meanings
all
the
any n o n - s p e c i a l
declared
fiers
to
are,
the
not wish
programmer.
of
The
identifiers
the
therefore,
to
program.
the
pro-
These
following
are
identifier::
READACARD
READ,A.CARD
R.E.A.D,A.CARD..
(d)
and
ALGOL-20 a l l o w s
Logic,
be of
type
Real
are
the
only
of
bit
assigned
in
the
G-20 w i t h
memory c e l l s
per
digits
a single
location,
but
variables
Also,
«-ype
simple
a precision
variable.
(about
otherwise
may u s e h a l f
variables
half,
variau'es
may
are
32 b i t
to
Half
of
variables
6 significant
act
as
42 b i n a r y
re<a
are
decimal
digjrs,
stored
digits)
variables.
gain
memory
space
at
logic
words,
w h i c h may b e
There-
the
precision.
and c h a r a c t e r
arithmetic
and B o o l e a n .
21 b i n a r y
Logic v a r i a b l e s
for
and s u b s c r i p t e d
only
programmer
of
integer,
stored
two s u c c e s s i v e
and occupy
expense
real,
simple
index.
a precision
fore,
as
variables
requiring
with
as well
both
or
Boolean
t o G-20
index
unsigned
manipulation
processes.
expressions.
registers
G-20
but
T h e y may b e u s e d
Simple v a r i a b l e s
act
otherwise
as
of
type
in
either
index w i l l
variables
of
used
type
be
Integer. The uses of logic and Index variables are complex to explain but
obvious to those ALGOL programmers who are also knowledgeable in G-20 machine
language.
For more information see Chapter 6e.
(e) The value of a real or half variable must either be zero or else
lie within the range given below:
real:
1.275,-57 3
abs(R) s
half:
1.275„-57 3
abs(H) == 1.645 +63
0
3.450„+69
10
integer and index variables will always take on integer values in the range
-2097152
logic variables are always positive.
<
I <
2097152
(= 2
)
If used as strings, they are four or
less characters in length, and if used as numeric quantities they are restricted
to
0
*
L
< 4294 967296
(= 2 )
The values of Boolean variables must be either true or false.
The G-20 replaces by zero any non-zero arithmetic result which is smaller
than 1.175,0-57 in magnitude; this situation is called an underflow.
An inter-
mediate arithmetic result which is greater than 3.450, +69, the largest number
0
representable in the G-20, is called an overflow.
An overflow during execution
of the object program will cause the run-time error message "RUN ERROR-EXPO" to
be printed, and terminate execution of the program (unless error recovery is in
use).
See Chapter 6b for further details on run-time errors.
An exponent overflow cannot occur during translation of the ALGOL source
program; violation of the restrictions on ALGOL-20 numbers given above will
cause a normal syntactic error message which will not, however, terminate
translation.
The number 3.450, +69 is the upper limit for the result of each individual
o
arithmetic operation in the evaluation of any arithmetic expression, regardless
of the types of the variables in the expression.
However, if the result of
the expression is assigned to a half variable, then a value greater than
1.645,+63 will result in an exponent overflow message as explained above. A
0
value assigned to an integer variable, on the other hand, will be truncated
21
modulo
cated modulo 2
message will occur.
(
AL.2.7
ARITHMETIC EXPRESSIONS
(a)
(2.3)[3.3]
In ALGOL-20, the asterisk ("*")
is used in place of the multipli-
cation sign <"x") of ALGOL-60.
(b) ALGOL-20 arithmetic expressions may contain the truncation operator "I" defined mathematically by
IX =
sign (X) * entier (abs(X))
That is, iX is simply the integer part qf X if X a 0, and is -(integer
part (-X)) for X < 0.
formed modulo 2
Thus, 1(1.7) = 1, I(-1.7) = -1. Truncation is per¬
= 4294967296; for example, 14294967298 = 2.
The truncation operator is unary, having exactly one operand which is
the complete expression immediately to the right of the "i" symbol. The
precedence of ' V is very high, so that "l" will be executed before "t" or
any other arithmetic operation (unless parentheses are used to force a difference order).
For example, "l X/Y means (*X)/Y and "XUY" means Xt(IY) .
H
(Truncation is done by an add-logical in mode zero of zero.)
(c) The truncation operator, "J", can be used to get the effect of the
integer divide operation, "r", which is not available in ALGOL-20.
If I and
J are integer variables, then
I -r J = i(l/j)
Notice that the "l" operator can operate on any integer or real expression,
and is therefore more general than ' V .
(d) When a variable of type half appears in an arithmetic expression,
the rules for determining the type of the result are exactly as if the half
variable had been of type rea.1.
In fact, Jull precision (42 bit) floating
point arithmetic is always £erformed on all variables other than Boolean and
logic in
G-20.
(e) The "+" and "-" can be used either as binary operators or else as
unary operators. v ^
e n
n«
+
a n d
"...
a r e
u s e d
a s
u n a r y
o p e r a
t o r s with V
in
the combination "T+" o-, »»_", parentheses around the exponent may be omitted.
The following table shows some examples of this rule:
The ALGOU20 Expressions
1
Means:
(both in ALGOL-20 and ALGOL-60)
Xt+Y
Xt(+Y)
Xt-Y
Xt(-Y)
Xti-Y
XtO(-Y))
(f) The precedence of operators and relations in ALGOL-20 is
i
(done first)
at&d_
T
- +
/*
- +
(used as unary operators)
(used as binary operators)
ft =-!>-!< > <
(done last)
That is, unless parentheses force a different order, i will be perfprmed,
then mod, then t, and so on. The unary operators + and - are special cases.
Unary + is ignored.
Unary - is performed on the expression on its right whose
operators have higher precedence tha,n it. For example;
q rood - a t b mod c * d
is
q mod((-(a t (b mod c))) * d)
(3,6)[3.4)
BOOLEAN EXPRESSIONS
(a) The Boolean operator V
("Implies") is not available in ALGOL-20,
However, for any Boolean expressions Bj and
the ALGOL-60 expression
B. o B may be replaced by either of the equivalent forms:
J.
£,
-B
1
- (B,
B2
-B )
2
(b) ALGOL-20 substitutes the equality symbol =
M
equivalence operator "2",
M
for the Boolean
Note that the ALGOL 60 report gives s
very
low precedence.
ALGOL-20 cannot distinguish between =
thus gives them the same precedence, Thus
A ^ B = C v D
and
=
and
is taken as
A ^ ;(B = C) s/ D, and parentheses must be used if any other meaning is
intended.
STANDARD FUNCTIONS
(2.4) [3.2.4]
ALGOL-20 has three built-in operators, MAX, MJN and MOD, which are
not in ALGOL.
These are defined mathematically as follows, where
E ,...E
2
are arithmetic expressions.
MAX (E , E , ... E ) =
the largest algebraic value of the N
expressions;
MIN (E
the smallest algebraic value of the N
expressions;
E
l
M 0 D
F
E , .., E ) =
2
;
=
E
l
E
? * * <
E
1
/
E
)
2
MAX and MIN may hav.. any number of expressions as arguments.
Note that MOD is written as an ^?rator between its twp arguments. The above
definition for MOD holds for all vai^s of E^ and E
2 >
but in the case where
both arguments are positive integer-valu^ expressions, then E
%
the remainder for ^
Although E
l
and E
2
divided by E
2
MOD E
2
Is
(and K E ^ V , ) is the integer quotient).
each appear twice in the deflation, they are actually
evaluated only once.
ASSIGNMENT STATEMENTS
(a)
(2 .5) [4.2]
In addition to the ":=" operator of the reference language
ALGOL-20 allows the left arrow ("<-") as an assignment operator.
The left
arrow has the same meaning as ":=", except when a non-integer expression
is assigned to an integer variable.
The assignment statement
<integer variable>
*- <non-integer expression>
result in truncating the value of the expression to an integer without
rounding.
If ":=" is used instead, the value will be rounded to an integer
in conformity with the reference language; however, the
operator pro-
duces more efficient object code.
(b)
In a multiple assignment statement, the "left part" variables
need not all be of the same type. For example, the sequence
n
REAL X ; INTEGER I, J ;
I «- X <- J := 3.7*X;
Is allowed in ALGOL-20,
The rule given in (a) above determines for each
integer left part variable whether or not rounding will occur,
LABELS AND GO TO STATEMENTS
(3.2)[4.3}
(a) Only identifiers may be used as labels in ALGOL-20; integer
labels are not permitted.
(b)
In ALGOL-20, GOTO and GO are both reserved identifiers, and TO
is ignored when it follows after GO.
Hence
GO TO Label
GOTO Label
GO Label
are all equivalent and permissible.
CONDITIONAL STATEMENTS
(3.3)[4.5]
(a) Because of character set restrictions, ALGOL-20 must make the
following substitutions for relational operators:
ALGOL-60
ALGOL-20
-»<
-• >
In addition, both "V" and
are allowed in ALGOL-20.
(b) There are some complex syntactic construction which were allowed
by the original ALGOL-60 report but were subsequently found to be ambiguous
or controversial.
One such ambiguity arises when a for statement comes
within the scope of an jj[ clause.
(1) Consider the following construction:
if... then
for
do
begin
if ... then Unconditional statement
else <statement>
end;
r
If the "begin ... end" pair is omitted, this construction becomes
ambiguous since the phrase
"else <statement>"
could belong to either the
inner or the outer if clause. ALGOL-20, in agreement with the 1962
revision of ALGOL-60, allows the "begin ... end" pair to be omitted, and
considers "else <statement>" to belong with the second <if clause>; i.e.,
the construction is treated as if the "be^in ... end" pair were actually
present(2) The following construction:
if ... then
for ... do Unconditional statements
else <statement>
is not actually ambiguous, Hpwever, the revision of ALGOL-60 syntax which
took care of case (1) also had the undesirable effect of outlawing construction (2) which is perfectly respectable. Therefore, ALGOL-20 will
allow (2) but will print a "Note 7" (see Chapter 6b) to point out that it
is inconsistent with revised ALGOL-60 syntax.
CONDITIONAL EXPRESSIONS
(3.5)
(a) ALGOL-20 allows certain constructions with conditional expressions which are unambiguous but illegal in revised ALGOL-60. The ALGOL-20
translator will flag any of these constructions with a "Note 4" message
(see Chapter 6b) to call the programmer's attention to the violation of
ALGOL syntax.
In ALGOL-20 the right-hand operand of a binary operator may be a
conditional expression without parentheses;
e.g., the second set of
parentheses may be omitted in:
Of
X > 0
then
X
else
Y) + (^f
Y > 0
then
3
else
X)
Note, however, that omission of the first set of parentheses, surrounding
the conditional expression which is the left-hand operand of the binary
operator "+'\ would change the meaning to the following:
if
X > 0
then
X
else
(Y + if Y > 0
then
Similarly, the following construction is legal in ALGOL-20:
X * if
A > B
then
3
else
Y + 2
3
else
X) .
AL.2.12
but will cause a "Note 4".
X * (if
It will be interpreted as:
A> B
then
3
else
(Y + Z)) ,
ALGOL-20 allows the analogous constructions with binary Boolean
operators and conditional Boolean expressions, and with relational
operators and conditional arithmetic expressions.
An example of the
last is the Boolean expression
(if BOOL
then
X
else
Y) <
if BOOL
then
3
else
Z
The expression with the first set of parentheses omitted would be interpreted as
if
BOOL
then
X
else
(Y < (if
BOOL
then
FOR STATEMENTS
(a)
clause;
3
else
Z))
(4.1) [4.6]
A left arrow may be used instead of ":=" in an ALGOL-20 for
"<-" will truncate and ":^=" will round each implicit assignment to
a for variable of type integer.
(b) The value of the controlled variable is not undefined upon normal exit from an ALGOL-20 for statement.
The value bf the for variable
upon exit depends upon the form of the last element in the for list, and
is in general just what would be obtained if the equivalent basic programs
(see section 4.1 of McCracken or section 4.6.4 of the report) were substituted for the for statement.
Thus, upon exit from an unti.1 or wh.ile
form of for list element, the for variable has the first value for whirh
the final test failed.
For example:
FOR
I
1
STEP
1 UNTIL
10 DO
S ,
leaves I = 11 when the for list is exhausted and control passes to the
next statement.
(c)
A fourth form
FOR
of for list element is permitted in ALGOL-20:
V
E,
STEP
F
WHILE
B
DO
S;
where E, and E- are arithmetic expressions, B is a Boolean expression, and
AL.2.13
S is any statement.
This is equivalent to the simple program:
V
LOOP;
«- E ;
t
IF
B
THEN
BEGIN
S
;
V
<- V + E ;
2
GO TO LOOP
END j
Notice that if the Boolean expression B is:
(V - Ej) * (E ) 5 0 then
2
the new _step_ ... while form of for list element is identical to the
Step ,.. until form.
expression E
2
However, when (as is usual)
the sign of the step
is knpwn to the programmer, the step ... while
form
(omitting the multiplication by E ) will be more efficient in both space
2
and time.
ARRAYS
(5.2, 5.3)fc.2. 3.1.4]
(a) ALGOL-20 arrays may be of type integer, real, Boolean, half, or
logic
Index arrays are not permitted.
(b)
A non-integer value of a subscript expression in ALGOL-20 is
not rounded, only truncated.
This may lead to hard-to-detect errors. For
example, suppose that the result computed for a subscript expression is
3.9999... Instead of 4 because of round-off error; this value will be truncated to 3, referring to the wrong element of the array. Thus, the plausible program:
FOR
X «_ 0
A
STEP
0.2
UNTIL
1.0
DO
[5 * X] - X ;
may not work correctly because of the round-off error in 0.2 which cannot
be exactly represented in a binary computer like the G-20.
The following
alternative will work:
FOR
I *~ 0
A [i]
-
STEP
1 UNTIL
5
DO
1/5 ;
(c) The speed of execution of an ALGOL-20 program does not depend
upon the lower or upper bounds of an array subscript, upon the order of
the dimensions, or upon the types of variables appearing in subscript
AL.2.14
expressions, however, the number of memory cells required by an array
does depend upon the order of the dimensions; the least number of cells
is required if the longer dimension is listed last.
OWN VARIABLES
(6.6) [5.0]
Own arrays may be used in ALGOL-20, but they must have fixed subscript bounds so that storage may be allocated to them before execution
begins; that is, "dynamic own arrays" are not allowed.
Own simple variables and own arrays are initialized to zero (or
false, in the case of Boolean quantities or '
1
in the case of logic
quantities) before execution begins.
PROCEDURES
(a) Parameters
(7.4) [4.7]
When the first occurrence of a label in a block is as an actual
parameter in a procedure call, then the ALGOL-20 processor must be forewarned that this identifier is a label. This requires that the label
identifier appear in a label declaration in the block head.
For example:
BEGIN
INTEGER I, J; LABEL L;
PROC (X, L) ;
L : I +- I + 1 ;
END ;
This is the only circumstance in which a label declaration is required in
ALGOL-20.
(b) Specifications
(7.5) [5.4.5]
All formal parameters in an ALGOL-20 procedure declaration must appear
in the specification part of the procedure heading.
(c) Recursive Procedures
(7.7)
Recursive procedures are not now available in ALGOL-20.
(d) Arrays, switches, and labels cannot be called by value.
AL.3a.l
CHAPTER 3
^
Input/Output Statements
3a.
Introduction
The official ALGOL-60 language does not include input/output
statements. Thus, ALGOL-60 can be used to describe computational
algorithms but not the process of reading input data from punched
cards, magnetic tape or disc, or the process of outputting intermediate and final answers onto printed pages, punched cards, magnetic
tape or disc. Each ALGOL translator, therefore, must contain its own
scheme for programming input and output operations.
ALGOL-20 includes an input/output ( l/0 ) system derived from
,,
n
the system used previously in the GATE language at Carnegie Tech.
1
The following pages contain both an introductory explanation and a
complete technical description of ALGOL-20 statements for reading data
cards and for printing and punching answers.
Chapter 3b is a primer on ALGOL-20 i/o which takes a particular
example of printed output and builds up its solution.
It is introduc¬
tory in nature, and concerns only printing. Punching requires only
simple extensions of the concepts used in printing. Chapter 3c is a
primer on READ which includes a completely worked-out example. Chapter 3d
contains a complete summary of all input/output instructions.
ALGOL-20 also contains provision for reading and updating files of
information stored on magnetic tape or disc. This mechanism is related
to the card reading, printing and card punching statements, but involves
additional complexity.
1
It is described separately in Chapter 6g.
The GATE input/output system is described in the manual: "20-GATE:
Algebraic Compiler for the Bendix G-20", Carnegie Tech Computation Center,
September 1962. The general principles of the ALGOL-20 input/output
system were the subject of a paper presented by A. J. Perlis at the Working Conference on Mechanical Language Structures, August, 1963, published
in Comm. A.C„M., 7 (Feb. 1964) p. 89.
o
o
o
r
CHAPTER 3b
O
P r i m e r
o n
ALGOL-20 Input/Output
Consider the task of programming a computer to print answers.
To control printing, such a program must specify two distinct kinds
of information:
(1)
Which values are to be printed, and
(2) The format in which the values are to appear on the page.
To supply these two kinds of information, ALGOL-20 contains two types
of statements:
NAME statements, which select the values to be printed,
and PRINT statements, which specify the printed format for these
values. "NAME" and "PRINT" are reserved identifiers in ALGOL-.20. In
general, each NAME statement is paired with a PRINT statement and the
two are used in parallel to control printing; each value specified by
the NAME statement must be matched with a format specification from the
PRINT statement.
The remainder of Chapter 3b is divided into sections, as follows:
A. The NAME Statement: Introduction
B. The Format Program: Introduction
C. The Print Buffer
D. An Example of Print Format
E.
Replicators: Introduction
A.
The NAME Statement: Introduction
A NAME statement in ALGOL-20 has the following form:
The reserved
identifier NAME followed by a pair of parentheses enclosing a name list.
For printing (or punching), the name list is a list of values to be
output and therefore is simply a list of arithmetic expressions (separated
by comraasj:
NAME ( < Arith Expr >,..., < Arith Expr »
When a value is needed by a PRINT statement, the value of the next
expression in the NAME list is computed and supplied to the appropriate
PRINT instruction. Expressions in the NAME list are evaluated in left
to right order, and the corresponding values are printed in the formats
specified by the PRINT instructions.
For example, to print the values of the ALGOL variables A, B and C
and also the value of the expression J B
2
- 4AC, the programmer may use
the NAME statement:
NAME
(A,B,C,SQRT(B T 2 - 4*A*C) )
along with an appropriate PRINT statement,
NAME statements may be more complicated.
For example, they may
contain for clauses and other forms of replicators which repeat the
selection of values in a manner analogous to the repeated execution of
an ALGOL statement by an ALGOL for clause. Replicators are discussed in
Section E.
B. The Format Program: Introduction
Suppose that the value 1.7 has been computed and is to be printed
by an ALGOL program. This number could be printed in any one of many
different formats; for example, one of the following forms might be
appropriate in a specific case:
1.7
+1.7
+00001.700
.170 +01
10
1.70 +00
w
17000 ,„-04
However, there is more to format control than specification of the forms
of individual numbers. Answers are generally to be printed in a readable
manner:
separated by blank columns and accompanied by suitable headings
and titles to identify the printed results. Therefore, a PRINT statement
must give the programmer control over the position of each number and
title on the line, the assignment of numbers to different lines, the
spacing of printed lines on the page, and the sequencing of pages, as well
as the form of numbers.
AL.3b.3
To control all these aspects of format, ALGOL-20 contains a
special "format language", which is used within PRINT statements. A
series of instructions in this format language forms a format program.
The individual instructions within a format program are separated by
commas.
The format language uses some of the same characters that ALGOL
uses, but with different meanings. Therefore, special brackets must
be placed around each format program to set It apart from the ALGOL
program in which it is embedded.
Unfortunately, there are no unused
symbols available in the G-20 alphabet for these format brackets, so
we use "<" (less than) and ">" (greater than) for this purpose. The
syntax of a PRINT statement is such that "<" and ">" symbols surrounding format programs cannot be confused with the same symbols in Boolean
expressions.
The simplest form which a PRINT statement may have is the reserved
word PRINT followed by a pair of parentheses which enclose a single
format program, or enclose a series of format programs separated by
commas. Each format program is itself enclosed in "<" and '*>" brackets.
The following PRINT statement, for example, contains a single format
program which consists of five format instructions:
PRINT ( < P, 37C, A=', + 2D.3Z, 2E »
,
The meanings of these instructions will be explained below. The effect
of this PRINT statement would not be changed if each format instruction
were enclosed in format brackets, so that the PRINT statement contained
five format programs each consisting of a single format instruction:
PRINT (< P >, < 37C >, < 'A=* >, < +2D.3Z >, < 2E »
C. The Print Buffer
Associated with the G-20 printer is a block of 120 consecutive
cells in memory, called the print buffer. These cells, numbered
1, 2, 3,..., 120, correspond to the 120 physical print positions or
"columns" in a line of printing.
The process of printing takes place in two steps: First, a
format program in a PRINT statement places the characters to be printed
into the print buffer, each character being placed into the cell
corresponding to the column in which it is to be printed.
In this
manner, the format program builds up an "image" of the line to be
printed.
Second, when the entire line has been formed, a format control
instruction must be executed to send all 120 characters from the print
buffer to the printer and actually print the line on the paper. The
format instruction which is generally used for the latter purpose is
'E , which is mnemonic for Execute. The E instruction prints the image
1
in the print buffer and afterwards automatically "erases" the print buffer
(i.e., clears It to 120 blank characters) In preparation for the next
line.
The print buffer behaves like other memory cells: Storing a new
character into a buffer cell replaces the character which was there
previously, while sending a character to the printer to be printed does
not (necessarily) erase it from the print buffer.
In particular, the
control instruction 'W executes the same printing operation as 'E' but
does not erase the buffer afterwards. Thus, the programmer may, if he
wishes, save part (or all) of the print image for printing on successive
lines.
Associated with the buffer is a pointer called the "character pointer"
or "CP". The value of CP is always the number of the print buffer column
into which the next character will be stored by a format instruction. As
each character is stored, CP is automatically stepped ahead (to the right)
by one so that successive characters are stored in left-to-right order
Into successive cells. Therefore, execution of a format instruction which
stores characters into the print buffer automatically leaves CP set to
the first column after the last character stored.
For example, if CP is
47 and a format instruction stores a number requiring 5 columns, CP
will be left at column 52.
Another pointer contains the "left margin" or "LM". The value
of LM is the number of the left-most column into which characters may
be stored.
Execution of the instruction "E" leaves CP reset to the
value of LM.
(Execution of "W" leaves CP unchanged.) There is also
a pointer which contains the "right margin" or "RM" —
the number of
the right-most column into which characters may be stored.
LM and RM have the values 1 and 120 respectively.
Initially,
Before each charac-
ter is stored into the print buffer, a check is made to insure that:
LM <: CP £ RM
If this relation does not hold, an "E" is automatically executed:
the
characters already In the buffer are printed, the buffer is cleared,
and CP is reset to the value of LM. The character is then stored into
the buffer. The mechanism for changing LM or RM is explained in
r
Section E of Chapter 3d.
D. An Example of Print Format
A particular print program will now be discussed in detail. Assume
that an ALGOL program computes all the values In a 40 x 10 array
(40 rows x 10 columns) COEF; these 400 values are to be printed along
with a value of a simple variable DELTA. A sample of the desired printing is shown on page AL.3b.7.
The printing begins with a title, "ADJUSTED COEFFICIENT MATRIX",
which starts in print position 37 of the first line on the page. The "1"
in the next printed line is in column 17, the "2" in column 28, etc.
The row numbers, down the left-hand column, are in print positions 6 and 7.
Each matrix element occupies nine positions in the printed line and is
separated from its neighbors by two blank spaces. The numbers to be
printed are all less than 1000 in magnitude, and four digits are to be
^
printed to the right of the decimal point. A minus sign is to be printed
immediately before the first digit if the number is negative. The
value of DELTA is to be printed with two significant digits in
"scientific notation", with a power of ten, as shown. No sign is
to be printed for DELTA. The step by step construction of the
necessary NAME and PRINT statements for printing this example follows.
First, consider printing the title. Three different types of
formating operations are needed for this purpose:
(1) An instruction is needed to begin printing at the
top of a page.
(2) An instruction is needed to indicate that the
information is to be printed starting in column 37.
(3)
Instructions are needed to specify the information
to be printed.
Since the title is a fixed string of alphabetic information, it is
convenient to include it entirely in the PRINT statement, with no
corresponding value in a NAME statement.
In fact, If only fixed infor-
mation such as a title were to be printed, no NAME statement would be
needed with the PRINT statement; this is an important exception to the
general rule that NAME and PRINT statements come in pairs.
To specify a title or any other fixed string of alphabetic characters to be printed, we use a format instruction called an alphanumeric
string instruction. This is simply the string of characters to be
printed, enclosed in quote marks. Such an instruction can thus be used
to print any character except the quote mark, since a quote within the
string cannot be distinguished from the quote terminating the string.
(A special format instruction Is provided for printing a quote mark —
see page AL.3d.6) The alphanumeric string instruction used to specify
the title Is:
•ADJUSTED COEFFICIENT
MATRIXMuuDELTAu
«u'
(Here and in the sequel we use the symbol "J' to represent a blank
column, where it is necessary to emphasize that a column is to be blank.)
Blank is a legitimate alphabetic character, so all blanks appearing in the
alphanumeric string instruction will appear as blank columns in the title
as printed.
1
A p J U S T f c p _ C O E f f _ I C I E N T
1
1
1 . 7 9 0 2
" " - 0 . 0 0 0 1
" 4 "
5
3
2
2
3
1
^>
• 0 . 6 5 1 1
- 1 . 6 9 1 0 "
- 0 . 1 1 9 8
»o.ooao
~ 9 3 . 9 1 5 3 '
- 0 . 0 0 7 7
0 . 5 9 5 6
- 9 8 . 2 4 2 2
4
1 . 7 4 9 2
- 0 , 0 5 7 3
- 1 1 . 1 6 1 0
- 2 , 6 4 0 6
• 0 , 0 0 9 5
- 7 9 . 3 9 0 6
- 9 8 . 8 1 3 4
- 4 . 5 8 1 1
• 0
- 2 0 , 9 8 1 8
• 0 . 1 0 8 2
0 . 1 2 1 0
1 , 8 6 4 0
- 0 . 0 1 0 2
9 7 5 . 0 9 7 4
0 . 0 0 0 2
- 0 . 0 2 2 8
• 4 5 , 1 3 9 8
• 0 . 0 4 7 2
- 1 7 . 3 6 7 4
- 1 9 . 0 5 1 4
- 0 . 0 0 0 1
• 0 , 0 0 6 1
- 0 . 0 3 7 7
0 . 0 5 9 1
• 0 . 1 0 2 8
- 0 . 0 0 4 7
- 2 9 , 7 4 0 4
- 1 9 6 . 5 0 3 0
7 . 9 5 8 0
7 7 7 , 2 6 2 6
0 . 0 0 0 2
- 0 . 0 6 9 2
5 2 , 0 7 1 8
- 0 . 0 8 2 6
0 . 0 0 0 0
- 0 . 2 0 4 2
• 0 . 0 0 0 2
0 . 0 0 1 4
0 . 1 6 6 9
0 . 0 0 1 3
- 0 . 2 2 1 0
- 1 8 . 2 9 0 5
- 2 2 . 9 5 1 6
1 4 6 , 4 7 3 8
0 . 0 0 0 1
0 , 0 0 0 0
- 0 . 0 0 2 5
3 6 8 . 0 1 1 0
- 5 9 4 , 3 0 0 2
- 1 . 7 9 3 5
- 7 . 2 8 7 8
-o.ooui
0 . 0 0 0 3
0 . 2 2 8 4
1 . 7 2 1 8
- 0 . 0 0 0 0
- 0 . 0 0 9 4
1 . 5 4 3 3
0 . 0 1 3 6
"
_
5 . 4 6 5 3
- 5 , 2 3 9 3
0 . 0 0 4 1
• 0 . 0 0 0 1
8
0 . 3 5 7 1
- 0 . 0 0 6 0
0 . 0 0 0 0
9
4 5 . 4 9 1 7
- 9 . 7 1 1 7
0 . 1 3 0 6
1 0
0 . 1 6 6 1
0 . 1 5 6 7
0 . 0 0 0 2
3 . 6 5 6 3
- 0 . 0 0 2 2
- 1 4 3 . 7 8 6 7
1 7 9 . 7 9 5 9
0 . 0 6 7 2
- 1 6 , 0 0 7 3
0 . 0 0 3 5
- 0 . 0 0 0 0
7 2 . 8 3 2 3 " " """
- 1 . 9 3 5 2
"
1 0
• 0 . 0 2 0 2
0.0 0 0 1
" " - U . 0 1 8 0 "
9
8
1 . 7 8 9 2
7
0 . 5 1 8 6
,
0 . 0 0 3 4
6
- 2 1 . 0 5 1 9 "
j
_
- 0 . 0 0 0 0
0 . 0 0 0 5 "
_
6
5
- 0 , 0 0 0 6
. 0 0 2 5 "
- 0 . 0 0 0 0
5 . 0 . - - 0 4
- 1 6 . 7 2 6 6
7 . 2 7 9 6 "
- 0 . 0 1 3 7
»
0 , 0 0 0 7
0 . 0 0 0 8
0
. 0 0 0 5 "
. D E L T A
- 0 , 0 0 0 0
0 . 0 0 0 0
" ~ " - 0
M A T R I X
- 0 . 0 0 0 0
"
3 2 3 . 8 6 5 4
0 . 0 0 0 3
. 0 4 4 6
0 . 0 0
0 8
- 0 . 7 8 7 1
"
O . 0 0 0 4
0 . 0 0 0 3
1 1
0 . 0 0 1 2
1 2
' - 0 . 0 3 4 5
-.0.
1 3
- 2 . 3 2 4 4
- 0 . 0 1 0 0
0 . 0 0 0 1
8 5 . 3 0 7 7
0 . 0 0 0 0
1 4
• 0 . 0 0 0 4
0 . 1 9 4 4
0 . 2 5 2 2
- 0 . 0 0 4 0
• 0 . 0 0 6 7
1 1 0 . 9 9 6 0
- 3 . 5 1 3 6
2 0 , 5 6 3 6
• 2 0 1 . 2 1 1 9
- 0 . 4 6 3 5
- 6 6 . 2 3 6 1
0 . 0 0 1 7
6 6 5 . 2 9 9 4
0 . 0 0 2 1
0 . 0 0 0 0
0 , 0 1 1 5
• 0 . 0 0 0 0
- 0 . 0 8 0 4
- 0 . 0 0 0 0
0 , 9 9 8 9
1 5
"°»i 7.
0 2 8 5
-o.oooo
- 0 . 0 0 4 1
69
16
1 7
ia
0 . 0 0 0 4
- 4 8 1 . 6 7 9 7
- 0 . 0 2 3 2
2 1 2 . 5 7 0 6
0 , 0 0 0 5
0 . 0 9 5 4
- 2 . 0 1 2 5
3 , 0 2 0 2
5 1 3 , 5 4 1 0
- 0 . 3 7 9 Q
- 8 1 4 . 4 / 4 0
0 . 1 2 1 8
4 6 2 . 6 3 7 9
- 1 9 , 9 3 9 6
- 4 6 , 4 4 2 9
3 5 9 . 0 7 0 4
0 . 0 0 1 4
• 6 . 7 0 6 7
0 . 0 0 0 1
1 2 7 . 0 4 1 8
- 7 4 2 . 4 8 1 4
- 0 , 0 0 0 1
0 . 0 0 0 4
- 9 2 5 . 1 0 3 5
- 3 . 1 9 2 8
0 . 0 0 9 7
- 0 . 0 0 1 3
- 0 . 0 4 2 3
• 0 . 9 3 4 7
- 0 . 0 0 0 3
0 . 0 8 4 7
2 9 . 2 2 0 4
•33.6923
- 0 . 0 2 1 9
• 4 . 2 0 3 1
- 1 4 . 3 6 4 0
- 3 . 1 7 8 2
• 0 . 0 0 0 0
- 0 . 0 2 2 6
5 7 5 . 6 6 0 2
- 3 5 . 2 6 0 7
2 . 2 2 6 7
0 . 0 0 0 0
0 . 0 0 0 0
• 0 , 0 0 7 4
- 1 4 . 9 8 2 6
0 . 5 9 4 7
0 , 3 1 4 6
0 . 0 0 0 0
1 . 2 6 6 3
2 6 . 1 3 1 5
- 0 . 0 1 3 9
- 0 . 0 0 3 3
- 1 1 2 . 8 0 8 4
0 . 0 0 0 0
2 6 3 . 9 8 1 6
0 . 0 0 0 1
1 . 1 1 2 7
0 . 0 8 0 5
- 2 1 9 . 9 6 3 2
2 2 6 . 8 1 4 6
0 . 0 0 1 2
. 0 . 0 0 8 8
7 7 , 9 8 8 9
- 0 . 0 0 0 2
0 . 0 0 3 4
0 , 3 7 2 9
- 0 . 0 0 0 0
- 8 8 . 2 3 1 1
- 0 . 0 0 9 4
0 . 0 0 4 3
• 1 . 0 3 8 2
- 3 3 7 . 7 2 8 9
0 , 0 0 7 9
.
- 0
. 0 6 5 9
1 9
- 0 , 0 0 3 6
4 2 7 . 1 1 3 0
2 0
0 . 0 0 1 0
0 . 2 1 7 2
0 . 3 3 9 8
2 1
0 . 4 6 7 5
0 . 0 0 3 9
- 9 2 . 6 . 2 7 4
2 2
0 , 0 0 1 8
6 . 5 4 4 5
0 . 6 7 0 4
2 3
3 2 0 . 5 4 8 5
- 0 . 4 4 3 6
- 2 1 2 , 2 1 9 9
2 4
0 . 1 5 9 5
- 0 . 0 0 2 0
2 5
- 0 . 0 0 1 0
- 0 . 8 1 7 7
'
0
. 0 0 0 1
0 . 5 4 8 7
1 . 0 3 1 6
• 0 . 0 0 1 7
0 . 6 3 6 8
- 1 . 5 1 2 0
2 6
0 . 2 3 8 8
0 , 0 0 0 1
0 . 0 0 8 9
• 0 , 0 0 0 1
5 3 5 , 3 5 4 6
- 0 . 0 0 8 9
- 1 3 . 3 0 4 4
0 , 0 1 3 3
2 7
- 0 . 0 0 0 2
- 0 . 0 0 0 6
- 0 . 1 3 1 9
- 2 1 4 . 9 8 9 1
" - 1 1 . 0 6 1 1
0 . 0 0 1 3
7 5 . 8 2 7 3
2 2 8 , 7 9 9 5
2 8
0 . 0 3 7 8
- 2 6 . 4 6 2 2
- 0 . 0 0 0 0
0 . 0 0 0 3
0 . 0 0 0 5
0 . 2 7 7 8
- 0 , 0 9 9 4
• 0 . 0 2 6 8
0 . 0 0 0 1
0 . 0 0 3 9
2 9
0 . 9 7 4 7
0 . 5 6 9 2
- 2 . 4 9 5 5
1 9 8 . 4 6 6 6
- 9 0 7 , 9 0 8 6
0 . 0 1 1 6
- 0 . 0 1 5 6
- 0 . 0 0 1 7
5 8 0 . 9 4 2 9
- 0 . 0 1 4 2
3 0
Q . 0 U 7 1
- 0 . 0 0 0 0
0 . 0 0 0 0
- 8 5 . 1 3 7 0
- 0 . 0 6 5 2
0.0 0 3 5
3 1
3 2
33
-.0. 0 0
0 3
. . A-1572 .
1 . 2 5 9 2
- 4 8 4 , 6 6 7 5 .
- 0 . 0 0 0 0 '
0 .
0 0 0 0
- 5 7 4 . 2 0 5 7
0 . 0 4 6 7
- 0 . 6 0 2 7
6 3 . 2 5 2 1
- 3 . 7 4 6 4
- 0 . 0 0 0 2
- 0 , 0 1 9 7
- 0 , 0 0 9 3
• 0 , 0 0 3 3
0 , 0 0 1 7
- 0 . 0 0 Q 1
0 . 0 0 0 4
- 3 0 7 . 9 8 4 7
0 . 0 0 0 4
• 6 3 2 . 2 3 2 2
1 3 9 . 1 3 0 1
0 . 0 0 3 0
- 8 1 0 . 0 7 9 0
3 3 . 7 1 8 4
• 0 . 0 0 9 8
0 . 0 0 0 5
6 4 , 7 9 5 2
0 . 0 0 0 5
0 . 7 8 0 2
0 . 0 0 0 9
* 0 . 0 9 8 3
- 4 9 6 . 9 9 7 2
1 . 7 1 8 2
- 0 . 0 0 0 2
0 . 1 5 6 2
1 3 8 . 8 6 1 5
0 . 0 2 2 4
1 1 0 , 3 8 5 4
0 . 0 0 0 0
- 0 , 0 0 7 9
0 . 0 0 4 3
0 . 0 0 0 0
- 3 . 9 5 7 6
- 0 . 0 0 6 0
0 . 0 0 0 2
0 . 0 0 0 3
- 4 8 8 . 2 5 6 7
0 . 0 1 1 5
-843,1841
1 . 4 9 7 6
0 . 2 2 0 9
- 0 . 0 4 2 0
0 . 0 0 6 8
3 6
• 0 . 0 2 0 4
- 0 , 0 0 0 1
0 , 5 3 9 4
- 4 , 4 2 8 2
- 4 0 . 3 6 6 6
0 . 0 0 3 1
0 . 0 0 0 0
- 1 3 6 . 9 7 6 6
- 0 . 0 0 1 8
0 , 0 0 2 1
3 7
0 . 0 0 0 2
- 0 . 0 0 0 0
- 1 6 5 . 2 7 4 0
- 4 5 7 . 8 5 1 5
- 0 . 0 0 0 1
0 . 0 0 0 0
5 6 , 5 3 5 7
0 . 0 1 4 2
6 6 . 8 9 7 9
- 0 . 1 8 9 6
3 8
2 1 . 5 V 2 Q
• 0 . 0 0 5 4
2 . 9 6 7 0
- 3 , 4 4 9 6
0 . 0 4 9 9
• 3 , 6 3 2 5
- 1 . 2 9 5 4
' 0 . 2 2 7 7
0 . 0 0 0 1
- 0 . 1 9 2 0
9 1 4 , 2 4 6 7
- 8 3 9 . 1 6 4 7
0 . 0 0 0 0
• 0 , 0 0 0 0
3 7 8 . 6 0 8 1
- 0 , 0 0 0 0
2 1 6 , 4 5 1 9
7 . 7 9 8 6
0 . 4 1 6 4
- 3 4 8 . 2 1 1 7
- 0 . 0 0 8 3
2 8 5 . 7 5 7 4
- 1 1 2 . 9 3 1 3
- 0 , 1 9 4 3
- 5 4 8 , 3 5 6 8
8 . 6 1 8 4
0 . 0 0 1 1
3 4
35
3 9
4 0
-o.oooo
- 2 6 . 0 0 4 2
• 0
. 0 0 0 2
• 4 5 . 7 2 8 9
0 . 2 0 9 8
0 . 0 0 0 1
o.oooo
This string is to be stored in the print buffer starting at
column 37, so CP must be set to 37 before the alphanumeric string
instruction is executed.
The format instruction to do this is "37C";
here "C" is mnemonic for "Column". Generally, executing an instruction
of the form "nC", where n may be any integer in 1 £ n 5 120, will have
the effect of setting CP to column n:
<1C, 37R> might also have been used.
CP
n. The format program
1C sets CP to column one, and
37R moves CP 37 columns to the Right. Similarly, nL moves CP n columns
to the Left. To summarize:
nC
has the effect
CP <- n
nR
has the effect
CP <- CP + n
nL
has the effect
CP *- CP - n
Therefore, the following format program will set CP to 37, place
the 40 characters of the string into print positions 37 to 76 of the
print buffer, and then print the buffer:
<37C, 'ADJUSTED COEFFICIENT MATRIX
- DELTA =
*, E>
This could just as well have been written as three successive format
programs by putting brackets around each instruction:
< 3 7 0 , <'ADJUSTED COEFFICIENT MATRIX
- DELTA =
<E>
but the first form is easier to punch. The instruction necessary to
store the value of DELTA into the print buffer is still missing. For
reasons which will be discussed later, the appropriate numeric instruction
is 1D.1ZL. Further, the title is to be printed at the top of the page.
The format instruction used to upspace the paper to the top of the next
page is "P". Thus, a complete ALGOL-20 program to print the first line
of the example might be
NAME (DELTA);
PRINT(<P, 37C, 'ADJUSTED COEFFICIENT MATRIX
- DELTA =
1D.1ZL, E>);
Equivalently, the following might be used:
PRINT«P, 37C, 'ADJUSTED COEFFICIENT MATRIX
NAME (DELTA);
PRINT (< ID. 1ZL, E » ;
- DELTA =
'» ;
T
^
Next consider the format for printing the number DELTA and the
numbers of the matrix itself. Numeric instructions are those instructions which place numbers into the print buffer; these numbers are
values which are obtained from the evaluation within the parallel NAME
statement.
A numeric instruction may be regarded as giving a "picture" of the
number to be printed. Generally, the following items must be specified
to define a number format:
(1) The form for printing the sign, if at all.
(2) The number of places, if any, to the left of the
decimal point, and whether leading zeroes are to
be inserted or left as blanks.
(3) The decimal point, if any.
(4) The number of places, if any, to the right of the
decimal point, and whether trailing zeroes are to
be inserted or left as blanks.
(5) The "exponent part" (power of ten), if any.
Items (2), (3) and (4), defining the format of the numeric part of
the number without sign or exponent, are specified by the number form
portion of a numeric instruction.
Item (1), the sign, is specified by
the sign part, which is part of the prefix, while item (5) is specified
by the suffix of the numeric instruction. The form of a numeric instruction then is given by:
<numeric instruction :: = <prefix> <number form> <suffix>
(We will see later that the prefix includes, in addition to the sign part,
a part which controls the printing of dollar signs.) The number form
gives a simple picture of the basic form of the number; as an illustration,
the matrix values in the example may be printed with the number form:
3D.4Z
Here "3D" indicates three Digits to the left of the decimal point, with
leading zeroes replaced by blanks; the period is a picture of the decimal
point which is to be printed; and "4Z" means four digits to the right of
the decimal point, with trailing Zeroes printed.
3.74 will be printed:
For example, the number
by 3D.4D
in the form
by 3D.4Z
in the form
,JU3.7400
by 3Z.4Z
in the form
003.7400
by 3Z.4D
in the form
003.74,.,^
by 3Z
in the form
004.
by 3D
in the form
uu3.74
uu
All blanks stored are shown explicitly byLi. Notice in the last two
examples that the number was rounded by adding five to the first digit
not printed, and then truncating the result. The syntax of number form
is as follows:
<number form> ::= <integer part> | <integer part>.|
<integer part>.fractional part> | .<fractional part>
<integer part> ::= <unsigned Integer> D
[ <unsigned integer> Z
fractional part> ::= <unsigned integer> D
| <unsigned integer> Z
If the integer part (fractional part) appears, at least one digit will be
printed before (after) the decimal point. For example, the number zero
printed with the numeric primary 3D.2D appears as
1
0.0 *. The total
number of digits specified must be less than 15.
In our example, DELTA is to be printed with one digit preceding and
one digit following the decimal point, so it may be printed with any one
of the following number forms:
ID.ID
1D.1Z
1Z.1D
1Z.1Z
The program which actually printed the sample included 1D.1Z to print
DELTA.
The prefix includes the sign part to specify the form for printing the
sign of the number.
If no sign is to be printed, this part is left empty,
as is the case for DELTA.
The array elements are to be printed with a
minus sign immediately preceding the first significant digit of each
negative number. The sign part to use in this case is
If in addition
plus signs were to be printed before each non-negative number, the prefix
"+" would be used instead.
The suffix portion of a numeric instruction is used to supply supplementary Information, such as scaling the number, printing an exponent or
special spacing. The format for the array elements is completely specified
by the prefix and the numeric primary portions, so the proper numeric
r
AL.3b.ll
instruction is -3D.4Z.
DELTA is to be printed in scientific notation:
shifted so that the Left-most digit is non-zero (if possible) and the
resultant exponent printed. The suffix "L" provides such printing, so
the numeric instruction 1D.1ZL is to be used to print DELTA.
E.
Replicators:
Introduction
In principle, everything which is necessary to print the example
has now been discussed.
However, writing or punching the NAME and
PRINT statements for the example using only the NAME and PRINT machinery
discussed so far would be very lengthy and tedious. For example, it seems
as if the NAME statement would have to be a simple list of all of
the 401 variable names DELTA, C0EF[l,l]
COEF[40,10], while the
PRINT statement would have to contain 401 distinct numeric instructions
in addition to alphanumeric string instructions and control instructions.
What is needed is a "loop" mechanism analogous to the ALGOL for statement; this mechanism is provided by replicators.
An ALGOL program which would operate in some way upon each element
of each row of the matrix COEF would presumably have the form of two
nested for statements:
FOR I «- STEP 1 UNTIL 40 DO
FOR J <- 1 STEP 1 UNTIL 10 DO
something with C0EF[l,j] ;
This Is essentially the form which is used in the NAME statement; the
"action" to be performed on C0EF[l,j] is simply "naming" its value
under the control of these FOR clauses. The following NAME statement
will supply all 400 values from the array COEF for printing:
NAME ($ FOR I <- 1 STEP 1 UNTIL 40 D O $
($ FOR J <r- 1 STEP 1 UNTIL 10 DO $
<COEF[l,j]»);
AL.3b.12
The "$" signs are necessary around a FOR clause when it is used as a
replicator in a NAME (or PRINT) statement. Also, the phrase being
replicated must be enclosed in parentheses, whether it is only a single
expression like (COEF[l,j]) or a complex expression which itself contains a replicator, like:
($ FOR J «- ....DO $
(COEF[l,j]))
This accounts for the three sets of parentheses in the example above.
The following is the syntax of a NAME statement:
<name statements ::= NAME ( <name list> )
<name list> ::=<name list elements | <name list>, <name list elements
<name list elements ::= <name expression | <replicator> ( <name lists )
<name expressions ::= <arithmetic expressions | <Boolean expression> |
<logic expression>
This syntax shows that any simple or complex list of "names" may be
enclosed in parentheses and replicated; such a replicated list may then
be a single element in another list. The following legal name statement
illustrates lists and replicated lists:
NAME ( A[l] , $ FOR J <- 1 STEP 2 UNTIL 3 DO $
(J, A[j], COEF[l,j]), A[7])
This example is equivalent to the following more simple statement:
NAME (A[l], 1, A[l], COEF[l,l], 3, A[ ] , C0EF[l,3], A [ ] )
3
7
As another illustration, refer again to the example, where the row
number is to be printed on every line of the matrix. The simplest way
to print these numbers is to give their values in the NAME statement and
use numeric instructions to place them into the print buffer. Thus, the
following NAME statement will supply (in addition to the array value),
the row number I just before the first element in each row:
NAME ($ FOR I <- 1 STEP 1 UNTIL 40 DO $
(I, $ FOR J *- 1 STEP 1 UNTIL 10 DO $
(C0EF[l,j])));
AL.3b.13
^-s
Since for clause replicators used in format programs very frequently
start at one and increase in steps of one, an abbreviated notation has
been provided for this special case. The replicator
<variable> -» $ Arithmetic expressIon> $
has the same meaning as:
$FOR <variable> «- 1 STEP 1 UNTIL Arithmetic expression^
Therefore, the NAME statement given above for the matrix with row numbers
may be written more compactly as:
NAME a-$40$(I,J-.$lO$(COBPCl.j]») ;
One more simplification is possible in this form; in the special case that
the Arithmetic expression> giving the upper limit of replication is a
constant (like "40"), or a simple variable (like "N") , it need not be
surrounded by "$" signs.
tor.
Thus, for example, "I -»N" is a correct replica-
"I -*N-1" is incorrect since dollar signs are required around the
arithmetic expression; the correct replicator would be "I -»$N-1$".
To print the column headings in the example, the values 1, 2,
10 must be supplied in a NAME statement. The simplest NAME statement for
the column headings is:
NAME (I
10(1) ) ;
That Is, I runs from 1 to 10, and it is the value of I itself which is
to be printed.
The same forms of replicators which are used in NAME statements may
also be used to execute repeatedly format programs or lists of format
programs in PRINT statements. Thus, instead of writing "<2D, 2D, 2D, 2D>",
we may write "J ~*4 <2D>".
In the case of a replicator in a PRINT state-
ment, however, the actual value of the replicated variable frequently is
not referred to; that is, the replicator is used simply as a counter. In
such a case, the variable in a " -* " replicator may be omitted; thus,
" -* 4 <2D>" may be used to get four repetitions of the format instruction
"2D".
Following is the syntax of replicators:
<replicator> ::= $ <for clause> $ | Oimpie variable> -»<limit> |
-><limit>
<limit> ::=
$ <arithmetic expression> $ | <simple variable> |
<unsigned integers
Some examples of these forms follow:
$ FOR J «- 2 , 3, K + 2 STEP 3 WHILE A [ K ] < K DO $
J
-»$
J
-» N
J ->
(A[l] / 2 ) + 3 $
3
^ $ (A[l] / 2 ) + 3 $
-» N
-+ 3
If the upper limit of replication has a value such that zero or
fewer replications are called for, then the phrase which is being
replicated will be skipped entirely.
As an illustration, the NAME and the PRINT statement for printing
the column heading of the example are:
NAME (I -» 1 0 ( 1 ) ) ;
PRINT « 1 6 G > , -> 1 0 < 2 D , 9 K > , < E » ;
Notice that the entire format program < 2 D , 9R> is replicated ten times.
The replicators are not part of the format language, and must therefore
appear outside the format brackets.
The variable I cannot be omitted from the replicator "I -» 1 0 " In
the NAME statement, since I is referred to, and is, in fact, the value
to be "named".
It would definitely have been incorrect to have used the
identical notation "I -» 1 0 " in our PRINT statement, since the same
variable I is already being used for a different replicator in the NAME
statement. Horrible confusion will result from using the same variable
as a replicator at the same time in both a NAME statement and its parallel
PRINT s ta tement.
After the instructions " < 1 6 0 ,
1CX2D,
9R>" have been executed, CP
will be set to print position 1 2 6 , past the RM of 1 2 0 . However, this
does not cause error printing because the two digits stored on the tenth
AL.3b.15
replication will be put into positions 115 and 116, and no attempt will
be made to store characters in positions greater than RM.
Finally, we set up a PRINT statement for the matrix Itself. Notice
the extra blank line every five lines. To get this blank line, we need
only execute an E instruction while the print buffer contains only blanks.
Thus, our PRINT statement will have the form:
PRINT ( -»8«E>, -»5 (format program for one line)))
The format program for one line could be:
<6G, 2D, 5K>, -+10 <-3D.4Z, 2R>
The entire program for the printed output of the example has now been
developed:
PRINT (<P, 37C, 'ADJUSTED COEFFICIENT MATRIX
- DELTA = '» ;
NAME (DELTA) ; PRINT «1D.1ZL, 4E» ;
NAME (I -» 10(1)); PRINT « 1 6 0 , -> 10 <2D, 9R>, <E> ) ;
NAME (I ~.40(I,J ~> 10(COEF
PRINT ( -»8(<E>, ->5 «6C, 2D, 5R>, -* 10 <-3D.4Z, 2R>, <E>)));
o
^
CHAPTER 3c
Introduction to READ
A useful way to visualize the process of reading alphanumeric
information from cards is to consider READ to be the reverse process
of PRINT. Recall that in printing, an image was formed in a buffer
and then sent to the printer to be printed.
In READ, however, the
image originates at the input hardware and is then sent to an input
buffer which is used by the READ statement in scanning string or
numeric values; these are then loaded into variables named by a NAME
statement. This buffer has a "CP", "LM", and "RM".
The NAME statement used with READ has the same form as with PRINT
except that it supplies the names of variables rather than the values
of the variables named. Therefore, the NAME statement used with READ
forms a list of ALGOL variables (either simple or subscripted), not
general arithmetic expressions, as are allowed with PRINT. Each numeric
or alphanumeric instruction assigns a value to successive variables
supplied by the NAME statement. Replicators may be used in the READ
statement with the same meaning as in a PRINT statement.
The following sequence Is incorrect:
NAME ( A + B ) ; READ ( < 3D > )
since the NAME statement names an expression which is not a simple or
subscripted variable.
The READ format program contains a list of instructions, very
similar to those in PRINT, which control the reading of new cards and
which specify the location and type of information expected to be found
in the READ buffer. Thus, the programmer, by using suitable READ format
instructions, is free to arrange his data cards in any format he desires.
The remainder of this chapter is divided into sections:
A.
Control Instructions
B. Alphanumeric Instructions
C.
Numeric Instructions
D.
Card Overflow
E. An Example Using READ
It is assumed that the reader has read Chapter 3b.
A.
Control Instructions
Just as the user uses E or W in a print format to control printing,
so does he use E or W in read format to control reading.
nE
Read n card images into the current READ buffer
and set CP to LM.
Only the last card image read
is available after executing this instruction;
hence, "IE" or "E" is the most common use of the
instruction.
nW
The action is the same as in "nE" except that the
card images are also printed on the program listing.
In a READ format program, as opposed to a PRINT program, the E or W is
usually the first instruction, rather than the last. The remainder of
the format program then controls the scanning of the characters read
into the read buffer. As in PRINT, the user has the ability to move CP:
nC
Set CP to column n.
CP *- n
nR
Move CP to the right n columns.
CP <- CP + n
nL
Move CP to the .left n columns.
CP «- CP - n
nB
Equivalent to nR.
B. Alphanumeric Instructions
As in printing, the user has the ability to input any string Information with an nA instruction:
nA
Scan the next n character positions of the read
buffer and store the information there into
U(n+3)/4) words from a NAME statement. The
information is stored four characters per word,
with the possible exception of the last word.
If the last word does not get four characters,
those characters it does get are stored rightjustified.
r
As an example, assume that the characters 'ABCDEu* appear on a card,
with the 'A' in column 15. The effect of executing the statements
NAME (L, M);
READ(<15C, 6A»
will be to store 'ABGD' into L and
into M. CP will be left at
'uuEu'
21.
Another possibility Is to supply fixed string information directly
from the READ statement, rather than from the card image. This ability
is particularly useful in setting successive elements of an array to
contain alphanumeric string, information. We have
'Atring^
The n characters between the quote marks
are stored into 4«n+3)/4) words from a
NAME statement, just as for nA. CP is
left unchanged.
Again, an example may be useful. Executing the statements
NAME(I-»5 ( A[l] ) ) ; READ« *THISuIS A .STRING* *>)
,
u
t
is equivalent to executing
A
CO «- '*THI ; A[2] <-
A [5]
1
'S.JS'; A ( > ]
-
\jAmS*;
A[4] «- 'TRIN';
'uaG*»
The number of characters between the quotes is 18, not a multiple of
four. Thus, the last two characters are stored right-justified in the
fifth named variable.
The last alphanumeric instruction provides the ability to read
Boolean values from a card.
nT
The next n columns are scanned, but only the first
non-blank column is examined.
If it contains T',
r
the corresponding name is set to true; otherwise,
the corresponding name is set to false. If the
corresponding name is not of type Boolean or logic,
the error situation "ILLEGAL BOOLEAN" exists and will
be treated as described below in Section D of Chapter
3d.
AL.3c.4
C.
Numeric Instructions
Two essentially different methods are provided for reading numbers
from cards:
fixed field and free field.
In the former, the programmer
must specify (and therefore he must know) when he writes the program
the columns on data cards in which the numbers will be punched. This
format information is then part of the compiled program. With free
field reading, the programmer specifies in his program only the number
of quantities to be read. The numbers may then be punched in any format
on the cards, separated by commas. Whether fixed field or free field is
selected, however, the same rules govern the actual form of the numbers
read.
(The distinction between fixed field and free field only has to do
with the columns used.)
Numbers on data cards obey the same syntax as
decimal numbers in program, with one addition:
If a •'/" is punched
before the number, either before or after the sign, the number will be
treated as an octal number.
If an exponent appears, it will then be
treated as an octal power of eight.
(In summary:
/ on data cards is
equivalent to 8F in program, but the latter notation is not allowed on
data cards. 8L and 8R are also not allowed on data cards.)
Fixed field reading will be described first. For each number, the
programmer may specify the following information:
1. Number of columns to be read.
2.
Treatment of blank columns. Blanks may either be ignored
or may be treated as if they were punched with a zero.
3. Decimal or octal conversion. The programmer may indicate
that the number is to be read as an octal rather than a decimal quantity.
4.
Scaling. The programmer may indicate that the value read is to
be multiplied by a power of ten (or of eight for octal conversion).
5. Alarm suppression. Normally, reading a character other than a
digit, +, -, decimal point, / or
10
will cause an alarm.
However, the
programmer may suppress this feature and cause such illegal characters to
be Ignored.
The syntax for a read numeric instruction is as follows:
<read numeric instruction> :: = <unsigned integer> D <read suffix>
<unsigned integer> Z <read suffix> | <int> F
1
<read suffix> ::= <empty> | <read suffix> <read suffix part>
<read suffix part> ::= H | N | E <integer>
<int> ::=<empty> | <unsigned integer>
The unsigned integer gives the number of columns to be scanned, and
may be as large as 127. If D is used, blank columns are ignored, while
using Z causes such columns to be treated as though they were punched
with a zero. The suffix H causes the number to be treated as an octal
quantity, regardless of whether or not a / is punched. A suffix of the
form E±n causes the number read to be multiplied by ten (or eight)
raised to the ±n power. The suffix N causes illegal symbols to be ignored.
Two error conditions may be detected in reading numbers:
SYMBOL and IMPROPER NUMBER.
ILLEGAL
(A detailed description of error messages
In READ is given in Section D of Chapter 3d.) The first indicates that a
character other than a digit, +, -, decimal point, / or „ has been read.
It is this error message which is suppressed by the N suffix. The second
message indicates that the number is improperly formed. For example, it
may have more than one decimal point, more than one „, a decimal point
after a ,etc.
1(>
In the numeric instructions just described, the field width or
number of columns to be scanned is specified by "nD" or "nZ" and is fixed.
A more flexible type of numeric instruction exists in the form of "nF" or
free field read.
"nF" specifies that n numbers are to be read and stored
into the next n names. Each number field is terminated by a comma, thus
allowing the data to be punched without reference to particular card
columns. Numbers may be punched in the same forms as for the fixed-field
READ and may continue from one card to the next. Blanks are Ignored except
that if an entire field is blank, the value of the corresponding name is
not altered instead of being set to zero.
An "*" may be used in place of a comma to terminate a number field. This
will stop the scanning of the card.
If fewer than n numbers have been read,
the remaining names will be left unaltered as though the corresponding number
fields were left blank. For example, executing the statements
^
NAME (A, B, C, D, E, F) ; READ(<E, 6F»
on the data card
12.6, /l4„+5, , 0 *
la equivalent to executing the statements
A «- 12.6;
B *- 8F14„+5; D «- 0;
It is clear, of course, that these statements leave C, E and F unaltered.
D.
Card Overflow
If a READ statement attempts to scan past the right margin, a card
overflow situation is said to exist. This situation is not treated as an
error, but is taken care of automatically by the system. As soon as an
attempt is made to read past the right margin, another card is read into
the buffer using either an E or a W, depending which of these the user
used last to read a card. CF is then set to LM (as usual), and the
character is read from that column.
E.
An Example using READ
To illustrate many of the concepts which have been discussed, a complete example follows, programmed in several ways. Assume an array A has
been declared
real array A[1:8O]
and that values for all 80 elements are to be read from cards.
From the
programmer's point of view, the simplest way to do this is the sequence
NAME (I ->80 ( A[l] ) ) ; READ(<E, 80F»
Thus the numbers may be punched, as desired, on as many cards as needed,
with successive numbers separated by commas. Assume instead that the data
cards are already punched, without commas. Each card contains eight
numbers, and each number is punched in nine columns with a column between
AL.3C.7
numbers whose contents are to be Ignored.
In this case, the READ
statement given above might be replaced by
READ( -> 10 ( <E>, -> 8 <9D, 1R> ))
A more interesting possibility is the following:
Suppose that the
numbers are punched onto 80 cards and that each card has punched in
columns 9 and 10 a subscript and between columns 12 and 30 a value.
That is, the 80 cards may be placed in any order and the number in
columns 9 and 10 indicates into which element of the array the value
Is to be stored. One way to program this is the following:
for i <- 1 step 1 until 80 do
begin NAME (j, A[j]) ; READ«E, 9C, 2D, 1R, 19D» end
This sort of construction will work since the code for naming A(j] is
not executed until after a value has been read into j. The reader
should satisfy himself that the following will also work:
NAME( ->80(j, A[j] ) ; READ( -> 80 <E, 9C, 2D, 1R, 19D»
r-
o
o
o
AL.3d.l
CHAPTER 3d
f"*'
A Complete Description of ALGOL-20 Input/Output
A.
Introduction
Chapter 3d is a complete, detailed description of input/output
statements in ALGOL-20. This material is organized to be used for
reference rather than for instruction. The user unfamiliar with the
concepts involved should read first Chapters 3b and 3c which are primers
on printing and reading, respectively.
Chapter 3d is divided into sections, as follows:
A.
Introduction
B.
NAME Statements and Replicators
C.
PRINT and PUNCH Statements
D.
READ Statements
E.
Buffer Manipulations and " j " - variables
F.
Control and Execution of i/O Statements
In the following, the term "format statement" will be used to refer to
either a READ statement, a PRINT statement or a PUNCH statement, since
the latter three types of statement are used to indicate the format of
data. The term "output statement" will be used to refer to a PRINT statement or a PUNCH statement.
B.
NAME Statements and Replicators
NAME statements are used to specify values to be output in a print
or punch operation or to specify locations into which data is to be stored
In a read operation. The NAME statement is not executed directly:
instead
it becomes active and functions as a list of values or locations which are
evaluated when needed by a format statement. To clarify this concept,
consider the program segment:
AL.3d.2
I *-7;
NAME( A[l] ) ; I *- 12;
PRINT«3D, E>)
The value of A[l2] will be printed -- not that of A [ ] .
7
Only one NAME statement may be active at any given time.
If several
NAME statements appear before a format statement, only the last executed
NAME statement will be available to the format statement. Hence in the
program segment:
NAME( A[l] ) ; NAME( A[2] ) ;
PRINT ( <format list> )
only the one element, A(Y| ,' is available to the PRINT statement. This
topic is discussed in detail in Section F, below.
A replicator is used in a NAME statement to indicate that an expression
or list of expressions is to be used repeatedly.
The replicator acts on the
list of expressions in a manner analagous to a for statement acting on a
statement In ALGOL. A replicator appears in one of three forms, the first
of which is:
$ <for clause> $
This replicator causes the replicated name list to be used repeatedly until
the for list is exhausted. An example is:
$ for I <r- 1 step 1 until 3 do $ { A[l] , B[l] )
which Is equivalent to
A[l] , B[l] , A[2] , B[2] , A[3] , B [ ]
3
The second form.of replicator is:
<simple variable> -» $ Arithmetic expressIon> $
This form is equivalent to
$ for <simple variable> <- 1 step 1 until Arithmetic expression> do $
with one important exception: The Arithmetic expressiori> is evaluated only
once, when the first name is actually called for.
sion
If the
arithmetic expres-
is a simple variable or an unsigned constant, the enclosing dollar
signs may be omitted.
For example:
I-.H
(J-$
2*1$ (A[l, j]))
The third form of replicator is:
-> $ Arithmetic expresslon> $
This form functions in a manner similar to the one immediately above, except
that the translator creates an internal counter to use in place of the
simple variable. This form may be used whenever the controlled variable is
not needed in the name list. As in the above form, the dollar signs may be
omitted if the
integer.
arithmetic expression
is a simple variable or an unsigned
For example, the construction
I -» N ( -» I (
) , A[l] )
Is equivalent to
•*\A[l],
' * ' , A [ ] , '*', '*', ' * \ A [ 3 ] ,
2
...,A[N]
Syntax for NAME Statements and Replicators
<name statements :: = NAME ( <name list> )
<hame list> ::= <name list elements | <name lists , <name list elements
<name list elements ::= <name expressions | <repllcator> ( A a m e lists )
<name expression> ::= Arithmetic expression> | <Boolean expression |
<logic expression
<replicator> ::= $ <for clausn $ | Aimple variable> -+<limit> | -»<limit>
<limit> ::= $ Arithmetic expression $ | Aimple variable> j Ansigned integers
C
FRINT Statements and PUNCH Statements
Most of the Instructions in an output statement serve to control the form
and positioning of information as it is entered in the output buffer; hence,
It is natural to discuss PRINT and PUNCH statements together. Because the
AL.3d.4
statements are so stmilar in function and in order to conserve memory
locations, PRINT and PUNCH initially share a common output buffer. This
means that storing characters with a PRINT statement alters any information
which may have been stored by PUNCH statements, and vice-versa.
In addition,
PRINT and PUNCH share the same CP, LM, and RM, so that changing CP in PRINT
changes it for PUNCH also.
Initially CP and LM are set to 1, and RM is set
to 120. Characters stored to the right of position 80 are ignored when
executing an "E" or "W" instruction in PUNCH. Users may have independent
buffers for PRINT and PUNCH by using the methods described in Section F of
this chapter.
Instructions appearing in output statements fall into one of three
classes:
Control instructions to specify the position of information in
the output buffer, alpha-numeric instructions to store constant information
and alpha-numeric strings, and numeric instructions to specify the form in
which numbers are to be stored.
Control Instructions
Associated with the output buffer are three variables:
^
CP, LM and RM,
the character pointer, the left margin and the right margin, respectively.
CP points to the "next" position in the buffer into which information may
be stored. LM and RM refer to the left-most and right-most positions In
the buffer into which characters may be stored. The following instructions
may be used to set or change CP or to output information:
nC
Set CP to position n (column n).
That is, CP «- n.
nR
Move CP n positions to the right. That is, CP «- CP + n.
nL
Move CP n positions to the left. That is, CP <- CP - n.
Moving CP to the left or right with nL or nR does not effect the
contents of the positions in the buffer which are passed over.
nE
Print (punch) one copy of the contents of the output buffer, output
n - 1 blank lines (cards), clear the output buffer to blanks and set
c
AL.3d.5
CP to the left margin LM.
•
nW
Print (punch) n identical copies of the output buffer on n
successive lines (cards) . The output is not cleared and CP is not
moved.
P
Upspace the paper to the top of the next page.
punch statements.)
(P is ignored in
In general a message will be printed as the
first line of the new page giving the date and a page number.
The date is printed starting at the left margin in the form
' 04 JUL 64', and the page number is printed in the last ten
columns before the right margin in the form 'PAGE nnnn ', where
nnnn represents the number of pages printed since the end of compilation, in <4D> format. Printing of the page header is under the
control of the programmer. He may restart the page numbering or
suppress the header completely.
See Section E below for details.
Executing "P" does not disturb the output buffer or CP. nP is
treated as IP or P, for any n.
In the above control instructions, and in the following alphanumeric instruc¬
tions, n Is assumed to be a positive, unsigned integer less than 512. If n
is to be one, It may be omitted.
For example, "E" Is treated as "IE".
Alphanumeric Instructions
Alphanumeric instructions are used for all storage into the output buffer,
except for storing of numbers. There is provision for storing strings which
appear in the output statement, for storing quote marks, for storing alphanumeric information from a NAME statement, for storing blanks, and for storing
Boolean quantities. Whenever a character is stored into the output buffer,
it is stored Into the position indicated by CP and CP is then incremented by
one. However, before the storing is done, a check is made that LM <• CP £ RM.
If this condition is not met, an "E" is executed and the character is then
stored at the LM of the next line.
'<string>' The characters of the string appearing between the quote
marks are stored. Any G-20 character except quote may be stored
by this instruction.
nQ
n quote marks are stored.
nA
n alphanumeric characters are stored. These characters come from
i((n+3)/4) names from a NAME statement. Each name, with the possible exception of the last, supplies four characters to be stored.
The characters from the last name are taken from the right end of
the word.
An example of an A primary may help. Assume that A[l] and
A[2] have been named, containing 'STRl' and '**NG' respectively.
Executing <6A> will cause 'STRING to be stored into the output
1
buffer. Had <7A> been executed instead, 'STRING* would have been
stored.
nB
n blanks are stored. nB has the same effect as a string instruction
with n blanks between the quotes.
nT
A Boolean value is stored. The number of characters stored into the
output buffer is min(5, n ) . The characters stored are taken from
one of three strings, depending on the value, v, of the next NAME.
If v is true, the string used Is 'TRUE^' ; if v is false the string
is 'FALSE'; and in all other cases the string is 'UNDEF'.
(The
latter may occur if the NAME is not a Boolean quantity.) The two
most useful forms of this instruction are IT, which stores 'T', 'F'
or *U', and 5T, which stores *TRUEu', 'FALSE' or 'UNDEF'.
Numeric Instructions
Numeric instructions are those instructions used to store numbers into
the output buffer.
Such an instruction may be regarded as giving a "picture"
of the number to be stored.
It includes the following information, some of
which may be omitted if not needed:
(1)
Sign control: The sign may be omitted or it may be stored.
If the
^
latter, two more choices are available: Positive numbers may or may not
have an explicit plus sign, and the sign may be either left-justified in
the field or it may appear just before the left-most digit.
(2) Dollar control: Numbers may be stored as dollar amounts, with
the dollar sign either left-justified or just before the left-most printed
digit.
(3)
Digits to the left of the decimal point: The number of such digits,
if any, is specified.
Leading zeros may be replaced by blanks.
(4) Decimal point: The decimal point may or may not appear, although if*
(5) is used it must appear.
(5) Digits to the right of the decimal point: The number of such digits,
if any, is specified. Trailing zeros may be replaced by blanks.
(6) Exponent part:
Several forms of "floating point" notation are avail-
able.
(7) Miscellaneous - the user may specify four more options: The number
may be stored decimal or octal; special spacings may be used; alarm output may
be suppressed; and the number may be truncated rather than rounded.
The syntax of a numeric instruction is as follows:
<numeric instruction^ ::= <prefix> <number form> <suffix>
The prefix contains the specification of items (1) and (2); the number form
contains the specification of items (3), (4) and (5); and the suffix contains
the specification of items (6) and (7).
Consider first the number form, with the following syntax:
<number form> ::=<integer part> | <integer part> . |
fnteger part> . fractional part> | . fractional part>
fnteger part> ::= <unsigned integer> D | <unsigned integer> Z
fractional part> : := <unsigned integer> D j <unsigned integers Z
Let the integer part be of the form vD or Z , and the fractional part be of
V
the form Tp or Tp.
If the integer (fractional) part is missing, let v (T|)
be zero. Then the number will be stored with v digits to the left of the
decimal point and Tj digits to the right. If the integer (fractional) part
contains a D, leading (trailing) zeros will be replaced by blanks, while the
Z form causes such zeros to be stored.
If v (Tj) is zero, then no digits will
AL.3d.8
be stored to the left (right) of the decimal point. If v CH) is non-zero,
at least one non-blank character will be stored to the left (right) of the
decimal point, even though a zero must be stored where D format would otherwise indicate a blank. The decimal point is stored whenever it is present
in the number form. The number is normally rounded by adding five to the
first digit to the right of the last digit stored. The sum of v and T| must
be less than 15.
The prefix is the specification of sign and dollar sign. The syntax
of the prefix is as follows:
<prefix> ::= <$ part> <sign part> | <sign part> <$ part>
<$ part> ::= <empty> | L$ | $
<slgn part> ::= <empty> j L+ j L- | + | In both the sign part and the $ part, the presence of "L" indicates leftjustified. A sign or dollar sign specified by "L+", "L-" or "L$" will be
stored into the output buffer before any digits or blanks, while a sign or
dollar sign specified by "+",
or "$" will be stored just before the first
non-blank digit stored by the number form. The order of storing is as follows:
1.
$ specified by "L$
2.
sign specified by "L+" or "L-"
3.
blanks from suppressed leading zeros in D-type integer part
4.
sign specified by "+" or "-"
5.
$ specified by "$"
6.
first non-blank character from number form
n
The sign part specifies one of three possible formats for storing the
sign of the number.
may be negative.
If it is empty, no sign is stored, even though the number
If it is
stored, taking one space.
or "L+", a sign, either '+* or
If it is "-" or "L-", a
will be
will be stored if the
number is negative and a blank will be stored otherwise.
The suffix part of a numeric instruction is used to supply supplementary
information:, scaling of the number, storing the exponent, special spacing
and other options. The syntax is as follows:
t
AL.3d.9
<suffix> ::= <empty> | <suffix> <suffix elements
<suffix elements ::= L j S <integer> j F <integer> j E <integer> |
H |K |N |T
The various suffix elements are explained below.
If an exponent is stored,
it takes six positions in the output buffer, in the form:
uwiddu'. No
more than one of the suffix elements S, L, F or E should be used on a given
suffix.
L
The number is left-justified in the field specified by the number
form, and the resultant exponent is stored. This is "scientific
notation".
E±n
The number is shifted so that its exponent equals ±n and the
exponent is stored.
Fin
The number is shifted so that its exponent equals in, but the
exponent is not stored.
Sin
The number form portion of a numeric instruction containing this
suffix must be of the form "<integer parts . ".
must appear.)
±n.
(The decimal point
The number is shifted so that its exponent equals
The resultant mantissa is then left-justified in the specified
field. The two shifting operations determine the position of the
decimal point, which is then inserted where needed. The resulting
exponent is stored.
H
The number is stored octal rather than decimal.
If an exponent is
stored, it is to be interpreted as a power of eight.
K
One of two special spacings is used in storing the number.
If a $
part appears in the prefix, the digits of the number are stored in
groups of three, separated by commas. If a $ part does not appear,
the digits are stored in groups of five separated by spaces. In
either case, the groups are counted left and right from the decimal
point. The decimal point, if present, serves as one of the spaces.
N
Possible alarm output is suppressed (see the text below), and any
digits which overflow the left end of the field are lost.
T
The number is truncated after the last stored digit, rather than
rounded as usual.
If any format other than L is used, it is possible that the magnitude of
the number is such that there are more digits to the left of the decimal
point than can be stored using the specified number form.
In such a case
(providing that the suffix N " was not used), alarm output will take place
n
with the use of "L" format.
If E or S format was called for, no extra
spaces will be taken. Otherwise the number will take six more spaces
than expected.
For example, the number 123 will be stored as 12 , +01 by
0
2D, but as 23 by 2DN.
Examples of Numeric Instructions
The value of the number to be stored is 4673900. The numeric instructions listed on the left side of the page will cause the storing; of the
corresponding strings of characters. The numbers at the right indicate
the numbers of buffer positions used.
7D
8D
9Z
7D.4D
7D.4Z
8DL
3D.1DL
1Z.2ZE+7
1Z.2ZF+7
3D.3ZF+7
.3ZF+7
+7D
-7D
L$+8D
L$-8D
$+8D
8Z ,K
L$8D.2ZK
3D.1DF+4
3D.1DF+4T
8Z.S+3
8Z.S+4
4DN
4D
8DH
4D.2ZHL
3ZHNTF+3
4
u
0
4
4
4
4
0
0
U
6
4
0
6
6
6
6
«
•
7
6
4
7
7
7
7
4
4
0
6
6
6
3
7
6
3
3
3
*
7
7
9
3
7
9
9
9
4
* 4
7
7 3
7 3
$ '_i + 4 6
4 6
$
L_l + $ 4 6
0 4 6LJ 7
$ u 4 > 6
4
4 6 7
4 6 7 * 3
4 6 7 3 *
4 6 7 * 3
3 9 0 0
4 6 7 4u
2 1 6 5 0
2 1 6 5 *
6 5 0
u
4
+ 4
4
*
* Alarm output used.
0
9
3
0
0
0
l_l
to
0
0
9
0
0
0
0
0 0
• 0
0
0 UJ
w + 0
+ 0 7
#
u i—1
00 0
0 lu
to
4U
n
-
6 7
9
9
7
7
7
3
7
0
0
3
3
3
9
3
0
0
9
9
9
0
»
-
0
0
0
0
9
0
0
0
.
0 0
. o0
9 0 0 0 i_i » + 0 3 u
9 0 0 0 L-l ID + 0 4 L_I
+ 0 3,_i
5 5 4
0 6
TO 0 4ui
10
7
8
9
12
12
14
11
10
4
7
4
8
8
10
10
10
10
14
5
5
15
15
4
10
8
13
3
_
Syntax for Print and Punch
For the purpose of this syntax, the G-20 characters "<" and ">" will
be replaced by "<" and
, respectively.
"<" and ">" will be reserved
for meta-Unguistic brackets in the Backus Naur Form syntax.
<print statements ::= PRINT ( <format list> )
<punch statements ::= PUNCH ( <format lists )
<format lists ::= <format list elements | <forraat lists , <format list elements
<format list elements ::= < <format program> > \
<replicator> 4 <format program> > | <replicator> ( <format lists )
<format program> ::= format instruction> |
<format program> , <format instruction>
<format instruction> ::=<control InstructiorS | <alphanumeric instruction> j
<numeric instruction>
<control instruction> ::= <int> C | <int> R | <int> L | <int> E | <int> W |
<int> P
Alphanumeric instruction> :: = <string> | <int> B j <int> Q | <int> A |
<int> T
<numeric InstructiorS ::= <prefix> <number form> <suffix>
<prefix> ::= <$ parts <sign parts | <sign parts <$ parts
<sign parts ::= <empty> j L + | L- | + | <$ parts ::=<empty> | L $ j $
<numeric primary> ::= <integer parts | <integer parts . |
<integer parts . <fractional parts j . fractional parts
<integer parts ::= <unsigned integer> D j <unsigned integer> Z
fractional parts ::= <unsigned integer> D j <unsigned integer> Z
<suffix> ::= <empty> | <suffix> <suffix elements
<suffix elements : : = L | H | N | K | T | S
<integer> | E <integer> |
F <integer>
<unsigned integer> ::=<digit> | <unsigned integer> <digit>
<integer>
<unsigned integer^ | + <unsigned integers | - <unsigned integer>
<int> ::=<empty> | <unsigned lnteger>
<string> ::= ' <proper string> '
<proper string> ::=<empty> |
<proper sting> A n y G-20 character other than quote>
AL.3d.12
Execution of Print and Punch Statements
^
From the definitions of PRINT and PUNCH statements, it is evident that
the forms of these statements are:
PRINT
( fie, fie,
fie )
PUNCH
( fie, fie
fie )
where "fie" denotes a format list
element. The fle's are executed in order
of appearance, from left to right. After the rightmost fie is executed, the
statement is terminated. Each fie is either a format program bracketed by
" < > " and possibly replicated, or a replicated list of fle's, separated by
commas.
In turn each format program may be a list of format instructions
( Eg., "3C, 2Q, E" ) . These instructions are also executed in left to
right order. It should also be noted that no replicators may appear inside
the "<" ">" brackets. If a format instruction requires a value, It will
cause a call on the corresponding NAME statement and evaluate the next expression to obtain a value.
D.
READ Statements
Most instructions in a READ statements are used to scan data which
has been read Into an input buffer and to store data values Into variables
which have been named in a NAME statement. As in PRINT and PUNCH, the
instructions fall into three classes: control Instructions to control the
reading of data card images into the buffer and the positioning of CP,
alphanumeric instructions to specify the manner in which alphanumeric data
is to be scanned and stored into variables, and numeric instructions to
specify the manner in which numbers are to be scanned, interpreted and stored
into variables.
(
r
Control Instructions
Associated with the input buffer are three variables: CP, LM, and
RM —
the Character Pointer, the Left Margin, and the Right Margin. CP
points to the "next" position in the buffer which is to be scanned. LM
and RM refer to the left-most and right-most positions in the buffer which
may be scanned. The following instructions may be used to set or change CP:
nC
Set CP to position n (Column n).
That is, CP *- n.
nL
Move CP n positions to the Left. That is, CP *- CP - n.
nR
Move CP n positions to the Right. That is, CP *- CP + n.
nB
Equivalent to "nR".
The following two instructions may be used to read data card Images
Into the input buffer:
nE
Read n card Images into the current READ buffer, and
set CP to LM. At the completion of this instruction,
only the last card image read is available to be scanned.
nW
The action is as in "nE", except that the card images
are also printed on the program listing.
In the above control instructions, and in the following alphanumeric
instructions, n is assumed to be a positive, unsigned integer less than 512.
If n is one, it may be omitted. For example, "W" is treated ad "1W".
Alphanumeric Instructions
Alphanumeric instructions are used to scan alphanumeric characters and
store string or Boolean values into variables named in a NAME statement:
nA
The next n character positions of the input buffer are
scanned, and the string of n characters there is stored,
four characters per word, into the next l((n + 3)/4)
named variables. If n is not a multiple of four, the
WNT LfSRARf
C M N E M E - I E U M MUVERSW
AL.3d.14
characters stored in the last variable are rightjustified.
'Atring^
The n characters of the
string
are stored as in "nA".
CP is not changed.
nT
The next n character positions are scanned and a Boolean
value is stored in the next variable named.
If the
first non-blank character scanned is the letter "T", the
value of the variable is set to TRUE; otherwise, It is
set to FALSE. CP is incremented by n.
If the variable
named is not of type Boolean or logic, the error condition "ILLEGAL BOOLEAN" is detected and treated as described
below.
Numeric Instructions
READ numeric instructions are either fixed-field of free-field. Fixedfield instructions consist of a primary specifying field width (the number of
1^
characters to be scanned) and possibly a suffix specifying additional information, such as scaling or octal conversion.
nD (nZ)
The instructions "nD" and "nZ" are used to form READ
primaries.
"nD" scans the next n character positions
of the buffer for a real or integer number and stores
it in the corresponding name. Any_ blanks scanned are
ignored, with the exception that if the entire field of
n character positions is blank, the value zero is stored.
A number preceded by a "/" is treated as an octal (base
eight) number, n must be a positive integer less than
128. The instruction "nZ" functions as "nD" except that
blanks are treated as zeros. The forms "nD.", "nD.nD"
".nD" and the corresponding Z primaries are not correct
in READ.
c
AL.3d.15
The suffix of the fixed-field instruction may be empty or may consist
of one or more of the following suffix parts:
H
The number is converted in octal (base eight) regardless
of whether or not it is preceded by a "/".
If the num-
ber has an exponent, the exponent is treated as a power
of eight.
E±n
The number read is multiplied by ten (or eight) to the
power ±n„
N
Any character other than a digit, +, -, decimal point,
/, or
10
is ignored if it is scanned.
CP is incremented
by one, and the next character is scanned. Normally,
scanning any character other than those listed above will
result in the detection of the error condition "ILLEGAL
SYMBOL".
In the numeric instructions just described, the field width or number
of columns to be scanned is specified by "nD" or "nZ" and is fixed. A more
flexible type of numeric instruction exists in the form of "nF" or free
read:
nF
n numbers are to be scanned and stored into the next
n variables named. Numbers
may be punched in the same
forms as for fixed-field read, and each number field is
terminated by a "," or a "*".
Blanks are ignored,
except that if an entire field is blank, the value of
the corresponding variable is left unaltered instead
of being set to zero.
A "*" terminates the scanning of the "nF" instruction.
If fewer than n numbers have been scanned, the
values of the remaining variables named are left unaltered,
as though the corresponding number fields were left blank.
After execution of "nF", CP points to the character position one position to the right of the last "," or "*"
scanned.
Card Overflow
If a READ Instruction attempts to scan character positions past the
right margin, a new card image is read using a pseudo control instruction.
This instruction functions as an "E" or "W" instruction, whichever has been
executed most recently. Scanning continues with CP set to LM.
Initially,
CP s 1, LM = 1, and RM = 84.
Error Messages
Several situations are detected
by the input routine as indicating an
error by the user, either in his ALGOL I/O call or in his data cards. A
standard error printout is provided, containing the following information:
1. The last card read is printed.
(If it was read by a W, it will
thus be printed twice.) The next line will contain an integer giving the
present value of CP and will also have a vertical arrow (t) pointing to
the column indicated by CP. Usually, this will be the column just past the
error.
2. A single line is printed identifying the particular error.
3. The standard ALGOL run error mechanism is invoked with RUN ERROR READ. The following error messages (item 2, above) are detected:
ILLEGAL BOOLEAN
An attempt has been made to read with a T instruction
into a variable of type other than Boolean or logic.
$$ - CARD READ
An attempt has been made to read past an end-of-file
mark. Reading more card images than are in the current input file results
in reading an end-of-file mark. This mark consists of special dollar signs
(internal representation 165g) in columns one and two. Attempting to read
still another card image causes the error condition "$$ CARD READ" to be
detected.
NO CARD READ
An attempt has been made to scan information before an
E or W instruction has loaded the input buffer.
(
IMPROPER NUMBER
In scanning a number with a numeric instruction,
an illegal sequence such as more than one decimal point, more than one ,
TO
or a decimal point after a „ has been detected.
ILLEGAL SYMBOL
In scanning a number with a numeric instruction, a
character other than a digit, +, -, decimal point, / or
w
has been read.
This message is suppressed by the suffix N.
E.
Buffer Manipulation and | - variables
As has been mentioned, an input buffer and an output buffer exist in
the I/O system. Associated with each buffer are three pointers: CP, LM
and RM.
It is frequently convenient for the programmer to be able to make
direct reference to these buffers instead of being restricted to using
format instructions to refer to them. For example, in all that has been
said up to this point no mention has been made of any way the programmer
can change LM or RM. To permit reference to the various pointers of the
I/O system, ALGOL-20 includes a special class of reserved words:
the bar-
variables. These variables consist of a vertical bar ("j") followed by
an integer. The j and the first digit of the integer must be in successive
columns of the same card, with no intervening blanks.
The format of a buffer will now be described using the print buffer
for definiteness. The buffer itself consists of 120 consecutive locations
in memory, corresponding to the 120 columns of the printer. Characters are
stored into the buffer by placing the G-20 representation of each character
in the corresponding word, right-justified.
The three pointers associated
with the buffer are stored in the three locations immediately before that
containing column one. "Column zero" contains CP, "column - 1 " contains RM
and "column -2" contains LM. Each of these three pointers has a name which
is available to the user, the name being a bar-variable. For the print
buffer, CP is in |205, RM is In |206 and LM is in j207. Thus the assignment
statement
|205 ^ 5
AL.3d.18
is equivalent to the format statement
PRINT « 5 0 )
Similarly, the programmer may change the right margin by storing into f206
with an assignment statement.
A similar situation exists for the input buffer. 84 consecutive
locations are provided for the actual read buffer. Column zero, called
(200, contains CP for reading; column -1, 1201 , contains the read RM; and
column -2, |202, contains the read LM.
Since PRINT and PUNCH share a common buffer, it follows that they
share a common CP, RM and LM.
The following table may help to clarify the preceding discussion:
Location
Initial Contents
1202
1201
1200
1
Meaning
84
READ
1
next 84 words
1207
1
|206
120
1205
1
PRINT and PUNCH
next 120 words
This gives the programmer convenient access to the three pointers, but
It does not provide a way to refer to the words in the buffer.
Since it is
frequently desirable for the user to have this ability, a means has been
provided for the user to cause a buffer to be in his own data area instead
of in the i/O system. Again considering PRINT, the user may direct that a
particular 123 element array is to be used as the buffer. The system will
then use the first three locations of this array as the three pointers and
the other 120 locations as the print buffer.
Since the array is in the
user's memory, he may refer to any column or to any pointer by the ALGOL
name he has given it. For example, assume that the declaration
logic array BUFF[ -2 : 120 ]
r
has been used and that the procedure call
BUFFER.SET ('PRINT', BUFF[o] )
has been executed.
(BUFFER.SET is a privileged identifier.)
k between one and 120, column k will be in BUFF[k].
RM will be in BUFF[-l] and LM will be in BUFF[-2].
Then for any
CP will be in BUFF[o],
It is important to
note that |205, |206 and |207 are specific machine locations and that after
executing the above BUFFER.SET call they will no longer contain the pointers.
BUFFER.SET may also be used to change the READ or PUNCH buffer, using
the string 'READ or 'PUNCH' as the first parameter to the procedure. As
1
for PRINT, the second parameter should be an array element which will be
set to correspond to "column zero" of the buffer.
Before calling BUFFER.SET, the programmer should be sure that the three
pointers he is about to put into effect contain reasonable values. BUFFER.SET
only makes one check:
it insists that the relationship
0 < LM < RM
be satisfied.
If it is not, LM will be set to one and RM will be set to 84,
120 or 80 for READ, PRINT or PUNCH, respectively.
BUFFER.SET detects two error conditions which are treated as run errors:
a first parameter which is not one of the three legal strings allowed, or a
second parameter which is not in the user's memory.
There are certain other bar variables associated with the input/output
system which are available to the user.
|210 and |211 are switches for
format and NAME, respectively. At any given time during the running of a
program when the user has NAMEd variables which have not yet been printed,
j211 will be non-zero.
(Its value is the location of a routine which will
supply the names to succeeding statements.)
If the programmer wishes to
cancel the effect of the extra names which have been supplied, he may do so
by setting |211 to zero.
Similarly, extra format elements which have been
supplied may be cancelled by setting |210 to zero. The programmer should
under no circumstances set either of these variables to non-zero values, or
chaos will result.
|212 and |213 are associated with the message printed at the top of each
page. Whenever the printer is moved to the top of a new page by the
execution of a P, the user may have a message and page number printed if he so
^
chooses. The system has been set so that the page numbers will start with
page one on the first after the completion of the compilation.
If the user
does nothing about it, each time a P is executed the first line of the new
page will contain on the left the date on which the program was run, and
on the right the page number. The page number is calculated by finding
out from the monitor the total number of pages which have been printed
since the run began and subtracting from this number the contents of 1212The contents of J212 is set on entry to the program to the number of pages
used by the compiler in compiling the program.
The user may change it at
any time if he wishes to alter the page numbering sequence.
[213 controls the message to be printed as part of the page header. If
it is negative, no page heading at all will be printed.
If it is zero, the
date and page number will be printed, as explained above. Positive values
should not be used in this location.
In the present version |213 > 0 will
be treated as suppressing the header, but in planned expansion it will have
a different meaning.
|214 is the up-space counter. After each line is printed, the printer
«
v
is up-spaced the number of lines indicated by |214. This location is set
on entry to the program to one, for single spacing. The user may set it to
two for double spacing, but other values are not recommended.
In particular,
setting it to zero saves paper but makes it hard to read the output.
|215 is the left-justify switch.
In processing number forms there are
certain occasions when either blanks or zeroes will be stored depending on
whether the programmer has used D or Z in his format.
If a blank would have
been stored and if, further, |215 is zero, then no space will be taken in
the print line instead of leaving a blank. Thus setting |215 to zero permits
the user to get left-justified numbers.
|215 is initialized to be non-zero.
These last few bar-variables may be summarized as follows:
|210
NAME
switch. £
|211
format switch. ? 0 •» there are formats to be processed
1212
page count
1213
page header switch. < 0 =* suppress; = 0 -» print; > 0 (do not use)
0
=» there are names to be processed
r
1214
[215
upspace counter
left-justify switch. = 0 => left-justify; ± 0 => don't
F.
Control and Execution of i/O Statements
The relationship between NAME and format statements Is given in the
following description of the execution of an input/output operation.
(1) An execution of a NAME statement sets the name switch, |2H, to
a positive integer, and sets an internal variable 6 to point to the first
name expression. Whenever J2U is positive the NAME statement which set
it so is said to be active. A NAME statement becomes active as encountered,
cancelling any previously active name statement.
When a NAME statement becomes active, a test is made to determine if
a format statement is already active ( [210 > 0 ) . If no format statement
is active ( |210 = 0 ) , control passes to the successor of the NAME statement.
If a format statement is active, the first name expression is evalu-
ated and sent to the format instruction pointed to by y
(See (2).)
6 is
changed to point to the next name expression, and control passes to the
active format statement.
(2) An execution of a format statement sets the format switch, |210,
to a positive integer. The format statement is then said to be active.
Because PRINT, PUNCH, and READ statements share the switch, at most one
format statement may be active at any given time. A format statement becomes
active when encountered, cancelling any previously active format statement.
The value (address) of a name expression may be needed during the execution of a format statement. If so, an internal variable, Y» is set to
point to the format instruction requesting the value (address), and a test
is made to determine if a NAME statement is active ( [211 > 0 ) . If not
( [211 = 0 ) , control passes to the successor of the format statement. If
a NAME statement is active, control passes to the expression pointed to by 6.
(3) In attempting to evaluate a name expression, a check is made to
determine whether 6 points to an expression or to the end of the NAME
statement.
If 6 points to an expression, it is evaluated and 6 Is set to
point to the next name expression (or to the end of the NAME statement),
\^
and the value (address) of the expression is sent back to the requesting
format instruction. When all name expressions have been evaluated, 6 points
to the end of the NAME statement.
In this case, no expression can be evalu-
ated, and [211 is set to zero Indicating that no NAME statement is active.
Control is passed to the common successor of the now inactive NAME statement
and the active format statement.
(See (5).)
(4) After the last format instruction in a format statement is executed,
|210 is set to zero, and control is passed to the common successor.
(See (5).)
(5) The common successor of an active statement and a statement which
has just become inactive is the successor of that statement which was most
recently encountered during the execution of the ALGOL program.
To clarify the above points, consider some examples of sequences of
input/output operations.
In the following, N(P) denotes a NAME statement with
P name expressions, F(P) denotes a format statement (PRINT, PUNCH or READ)
which requires P values or addresses, S denotes an arbitrary ALGOL statement,
and S' denotes any ALGOL statement which is not an input/output statement.
A:
Q
N(6); S'; F(6); S;
Executing N(6) sets |211 > 0 and sets o to point to the first name
expression.
S' is executed and eventually F(6) is entered.
Because N(6) is
already active, each request for a value or address will be filled by N(6).
When the execution of the last format instruction is complete, F(6) becomes
inactive, and S is executed. N(6) is still active, but 6 points to the end
of statement.
In this state, any request for a name expression will render
N(6) immediately inactive. A NAME statement followed by a format statement
is the simplest and most frequently used sequence.
B:
F(5); S*; N(5); S;
B illustrates an alternate sequence, in which the format statement pre-
cedes the NAME statement. Executing F(5) sets |210 > 0, but no requests for
name expressions can be filled because there is no active NAME statement.
V is set to point to the first requesting format instruction, and S* is executed. When N(5) becomes active, it determines that F(5) is already active.
c
r
AL.3d.23
^-v
The first name expression is evaluated and sent to the format instruction
indicated by y.
Eventually, ,the last format Instruction in F(5) is exe-
cuted and F(5) becomes inactive. As in example A, N(5) is still active
but any request for a name expression will render it inactive. Control
then passes to S.
C:
N(4); N(2); F(3); S'; N(l); S;
C illustrates a more complex situation which is probably a programming
error. N(4) becomes active, but is cancelled by N(2).
N(2) and F(3) function
aa in example A, except that when F(3) requests a third name expression, N(2)
becomes inactive. S* is executed and N(l) encountered. N(1) now supplies
the requested name expression to F(3) and F(3) becomes inactive, passing
control to S.
Users should be wary about using sequences such as described
in C as it is very easy to produce an error which has repercussions on many
other input/output operations in the program. As a safeguard, the name and
format switches may be zeroed as described In Section E of Chapter 3d.
o
o
o
AL.4.1
CHAPTER
SYSTEM
4
STATEMENTS
System statements are instructions to the ALGOL-20 translator which may
be used to modify certain aspects of the translation process. That is, a
system statement is executed by the translator at compile time rather than
by the object program at execution time. System statements are executed as
they are encountered by the translator as it scans once through the ALGOL
source program and take effect immediately thereafter. All system statements
except those marked with "t" may be used anywhere in the source program.
Each system statement is punched on a separate card which contains "SY"
in columns 1 and 2. The system statement itself may be punched on the card
anywhere between column 4 and the current right margin (see RIGHT MARGIN
below).
A system statement generally has the form:
< statement name >
< parameters >
Those system statements which have a fixed number of parameters are terminated
by a blank following the last parameter. The rest of the card may be used for
comments. The system statements which have a variable number of parameters
are terminated by the end of the card, so comments cannot be included on such
a card.
System statements which may not contain a comment on the same card
are marked with a dollar sign ($).
Each system statement type will now be described and explained.
In the
following, "n" will always stand for an unsigned integer. The system statements
marked with asterisks (*) control printing but will never themselves be
printed.
Printing of the other system statements may be suppressed by the
system statement:
"PRINT NO SYSTEM".
Blanks are not ignored when scanning system statements. There must be at
least one blank between words and/or numbers and none in words or numbers.
PRINT CONTROL
(1)
PAGE
(No parameters)
The effect Is to skip the compilation listing to the top of
the next page. The PAGE statement itself will be printed on
the first line of the new page.
*(2)
LINE n
The effect is to upspace the printer by n lines. An attempt
to upspace beyond" the bottom of the current page
will leave
the paper at the top of the next page.
*(3)
SINGLE
(No parameters)
*(4)
DOUBLE
(No parameters)
These statements cause the compilation listing which follows
to be printed with single or double line spacing, respectively.
If neither statement is given, the translator assumes SINGLE.
*(5)
INDENT
n
K <- n
INDENT
+n
K <- K + n
INDENT
-n
K *- K - n
The indentation constant, K, specifies the number of print positions to the right of the text left margin that the compilation
listing will be printed.
The translator normally assumes
"IDENT 0". An IDENT card modifies K as given above.
If this
rule leaves K outside of the range 0 3 K £ 21, then
K <- max(0, min (K,21)).
Note the difference between "IDENT 2"
and "IDENT +2": The former sets K to 2 and the latter increments
K by 2.
See Chapter 6c for a discussion of the format of the
compilation listing.
S(6) PRINT
The user has the ability to turn on or off the printing of various
aspects of his source program.
In general, if he does not spec-
ify otherwise, his source program along with octal addresses,
notes from the translator, and system statements will be printed,
while routines accessed from the symbolic library will not. The
* Not printed
$ Comment not allowed
^
printing of each of ADDRESSES, NOTES, SYSTEM statements and LIBRARY
routines may be controlled individually by the programmer by suitable PRINT statements. We have the following syntax:
<PRINT statements
<parameter string>
<parameter>
::=
PRINT <parameter string>
::= <parameter>, | <parameter string> <parameter>,
::= <control word> j NO <control word> | NO | EACH
<control word>
::=
PROGRAM | ADDRESSES | NOTES | SYSTEM j LIBRARY
A PRINT statement is interpreted by treating each of the parameters
in the parameter string in order from left to right across the card.
The control word ADDRESSES refers to the octal addresses printed
down the left side of the page. NOTES refers to possible error
notes printed by the translator.
(See Chapter 6b.)
SYSTEM refers
to system statements (except those which never print).
LIBRARY
refers to routines accessed from the symbolic library, as described
below. PROGRAM refers to the listing of the source statements,
along with notes, addresses and associated system statements.
A parameter consisting solely of a control word has the effect of
turning on the printing of the corresponding part of the assembly
listing as described above, while a parameter of NO followed by a
control word turns off that part.
The parameter EACH is equivalent to the parameter string "PROGRAM,
ADDRESSES, NOTES, SYSTEM, LIBRARY", and the parameter NO is equivalent to "NO PROGRAM, NO LIBRARY".
The parameter NO PROGRAM suppresses printing of the source program
along with the associated addresses, notes and system statements,
overriding any previous parameter of ADDRESSES, NOTES or SYSTEM.
If PRINT PROGRAM is in effect, however, then NO NOTES, NO ADDRESSES
or NO SYSTEM will suppress printing of these individual features.
It is not possible to print notes, addresses or system statements
without printing the corresponding source program images. If
PRINT NO PROGRAM Is In effect, PAGE and LINE have no meaning and
thus are ignored by the translator.
The parameter LIBRARY has a function analogous to PROGRAM, except
that LIBRARY takes effect only when a subsequent SY LIBRARY system
statement starts inserting library images; then, having
PRINT LIBRARY (PRINT NO LIBRARY) in the "main" program text
has the same effect as having PRINT PROGRAM (PRINT NO PROGRAM)
as the first library image. These library images may themselves contain PRINT system statements; these will control
printing only within the library segment, so that the PRINT
status in effect when the SY LIBRARY statement was encountered
will be restored at the end of the LIBRARY segment.
If SY
LIBRARY occurs within a set of library images, print control
works, as described above, calling the outer set of library
images the main program and the inner set the library images.
The PRINT parameters are always "pushed down" when an SY LIBRARY
system statement is encountered, and the "LIBRARY" switch on one
level becomes "PROGRAM" switch on the next level.
In the absence of any PRINT system statements, the ALGOL-20
translator assumes PRINT EACH, NO LIBRARY.
MISCELLANEOUS
(7) RIGHT MARGIN n
Starting on the next card, the translator will scan column 4
through n for the text of ALGOL, WHAT, and system statements,
where 40 ^ n 5 80.
If n is not in the proper range, an error
message is given and the right margin is not changed.
The trans-
lator initially assumes RIGHT MARGIN 72.
(8) LIBRARY <identifier>
The translator inserts into the program at this point the segment
of ALGOL source program text (generally a procedure) which is
filed in the symbolic library under the name <identifler>.
t(9)
n ABCONS
The translator will reserve n G-20 locations for storing "abcons"
and n locations for storing "adcons" during both translation and
execution. Abcons are numbers and alpha-numeric strings which do
not appear in format primaries. Adcons are constants and temps
t Before the first begin only
for format replicators and small integer constants used as
actual parameters to procedures.
If no ABCON statement is given, the translator assumes
"200 ABCONS".
An ABCON statement may only occur at the very beginning of the
(10)
program
before the firBt begin.
SEGMENT
nl, n2
The integer nl specifies the segment number, and must usually
satisfy 1 s nl 5 S.
Segments 1 through N are temporary segment
and thus are not saved after the end of the user's run; permanent segments with numbers greater than N, are available upon
request to the Computation Center.
Since the number of temporary
segments may change in the future, no value for N is given here.
Its value can be found in the Users Manual, Section 1.5. The
integer n2 specifies the number of files which will be required
for the segment; each file contains 10240 words. If segment 1
10
requires 2 files, the next available segment is segment 3.
The number of "words" printed out at the end of an Algol program
is the number that must be dumped out if the program is dumped as
a segment.
See Chapter 6f for a complete discussion of segments.
(11) RELEASE WHAT
(12) RELEASE SYMBOLIC LIBRARY
The user who does not need WHAT or the symbolic library may reclaim
the space used by these parts of the ALGOL compiler. This allows
longer programs to be complied.
Since WHAT is below the library
processor in memory, no space can be reclaimed until WHAT is
released.
The RELEASE'S may be done, however, in either order and
at any time during the compilation.
Releasing WHAT reclaims /1400
(768 ) words; releasing the library will reclaim an additional
10
/600 (384 ) words. Attempting to use WHAT or the symbolic library
10
after it is released will cause a compile error.
AL.4.6
(13) DEBUG
n
This system statement is designed for the user with some
knowledge of G-20 machine code and a general knowledge of
the Algol-20 translator who wishes more specific information on the translation of a particular statement. This
statement controls the printing of up to four columns of
information after each ALGOL text card:
character scanned
postfix produced
code produced
internal variable equivalents
This information is printed one item per line as it is
generated.
An internal variable equivalent is printed out
for each identifier declared.
n = 0 turns it off.
n > 0 turns on the printing,
CHAPTER 5
^
THE ALGOL LIBRARY
The primitive operators available to the ALGOL programmer include
arithmetic operators such as +, *, and t (exponentiation), and elementary mathematical functions such as SIN, EXP and ARCTAN. However, the
programmer may need matrix inversion, numerical integration, leastsquares curve-fitting, or calculation of eigenvalues and eigenvectors
as basic operations in the solution of a particular programming problem.
Since the last are somewhat less frequently used operations, they have
not been provided as a part of the ALGOL language itself.
Instead, these
and other standard procedures are provided in a procedure library from
which the programmer may call any library procedures which he needs in a
particular program.
Since the library is in no sense complete, existing
procedures of general interest or the need for new procedures should be
brought to the attention of the Computation Center staff.
There are two libraries in the ALGOL-20 system:
the relocatable
library and the symbolic library. The relocatable library contains for
^
the most part those procedures which must be coded in machine language,
such as DISC.READ and DISC.WRITE. The routines in this library are
assembled once by the Center staff and placed in the library as relocatable binary machine instructions. From there they may be accessed by the
user and loaded Into any ALGOL program.
This loading process is signifi-
cantly faster than compiling a copy of the procedure into the user's
program.
The symbolic library contains pieces of ALGOL text. This text will
typically be a procedure declaration, but it need not; text for several
procedures, a block, or an arbitrary sequence of ALGOL instructions may
be filed as a single entry in the symbolic source language library. Procedures in this library are usually those which can be written more
conveniently in ALGOL than in machine language; for example, SIM, the
Simpson's Rule integration procedure. While a more efficient procedure
might be written in relocatable machine language, there are at least two
advantages to writing the procedure in ALGOL:
First, the routine can be
written and debugged in less time and with less effort by using ALGOL,
^
and second, ALGOL text is more easily read. Anyone who is interested in
the detailed operation of the procedure may get an ALGOL listing of the
procedure as it is compiled into his program.
(See the discussion of
(
print-control statements In Chapter 4.)
Since all the objects in the libraries are not procedures, the term
"routine" is applied to an entity in either library. Thus, a routine may
be a closed subroutine, a procedure, several procedures or an arbitrary
i
sequence of ALGOL instructions.
The descriptions of all routines in this
chapter state whether the particular routine is in the symbolic or relocatable library.
Since there are different processes involved in processing symbolic
I
source language and relocatable binary routines, there are different
mechanisms for accessing symbolic and relocatable routines. Symbolic
library routines are accessed by means of a SYSTEM statement. (See Chapter 4
for a complete discussion of SYSTEM statements.)
SY
|
LIBRARY
The card image
<ldentifler>
will cause the text for the routine <Identifier> to be compiled into the
program at that point. The routine may then be used in the same way as
f
j
any other routine which appears in the program.
V,
Relocatable routines are accessed by a slightly more complex mechanism;
they must be declared as library procedures in the head of the block in
I
|
which they are used. The syntax of declarations is extended to include a
library procedure declaration:
<library procedure declaration> :: = library procedure identifier list>
1 library <type> procedure identifier list>
Thus the following are examples of library procedure declarations:
library procedure DISC.READ. DISC.WRITE,SLEW;
library real procedure ZILCH, SINH, GOSH;
These declarations have the same scope as any other ALGOL declarations; thus
the name of a library procedure may be redeclared in other blocks to be any
other ALGOL construct. Therefore, it may be necessary to declare the same
library procedure in several different blocks. No matter how many times the
procedure is declared only one copy of the routine will be added to the
program.
(
AL.5.3
As with any other library, the ALGOL library also has a librarian,
which is used to update and edit the library.
Using the librarian, the
user may add his own routines to the library on a temporary basis. For
a description of the librarian, see the ALIBN Manual.
The remainder of this chapter is a set of descriptions of the
routines currently available in the relocatable and symbolic libraries;
these are arranged within each library alphabetically according to the
procedure name. Also, for completeness, writeups are included for "standard
routines" - those routines.which are built into the system and whose names
are reserved identifiers. As these routines are automatically included in
any program which calls on them, they do not have to be declared.
In fact,
any attempt to fetch them with an SY LIBRARY card or with a library
procedure declaration will be detected as an error.
The reference for numerical method given for many of these routines is
"1604 Routines". This refers to the book, Some Basic 1604 Mathematical Subroutines. Publication 061 of Control Data Corporation, Minneapolis, Minnesota.
A copy of this book Is available at the Computation Center for reference.
O
!
o
o
AL.5.ARCTAN.1
Standard Function
PROCEDURE SPECIFICATION
real procedure ARCTAN (X); value X; real X;
PURPOSE
ARCTAN finds the inverse tangent of X in radians in the range
from - TT/2 to + n/2.
It operates correctly on any number given as
input.
METHOD
Described on page G-l of "1604 Routines".
TIMING and ACCURACY
The result is produced in 1.25 milliseconds.
The error is less than 1 -11.
10
AL. ARCTAN.2
O
O
1
o
AL.5.C0S.1
Standard Function
PROCEDURE SPECIFICATION
real procedure COS (X); value X; real X;
PURPOSE
COS finds the cosine of X, where X is in radians and may be either
positive or negative.
METHOD
COS uses the sine routine, using the identity
COS (X) = SIN (X + TT/2) .
ALARMS
RUN ERROR - SINu
jx| > 2,097,152 =
2 1 21
For values beyond this point the algorithm breaks down.
TIME and ACCURACY
The result is produced in 1.08 milliseconds. The relative error
is about 5 -11.
10
AL.C0S.2
O
o
o
^
ALGOL Symbolic Library
PROCEDURE SPECIFICATION
PROCEDURE C U R F I T
(K, A , B , M , X , Y , W , N , A L P H A , BETA, S , SGMSQ, X O , GAMMA, C , Z ,
R, O R T H , P O W , ERROR) ;
VALUE K, M, N , X O , GAMMA, R; INTEGER K, M , N . R;
ARRAY A , B , X , Y , W , A L P H A , BETA, S, SGMSQ, C , Z;
REAL X O , GAMMA; BOOLEAN O R T H , POW; LABEL ERROR;
REFERENCES
1. Algorithm 74, Comm. ACM, January 1962
2. Peck, J.E.L. Polynomial Curve Fitting with Constraints, SXAM Review, April
1962, pp. 135-141
PURPOSE
CURFIT finds the polynomial of degree N which passes through the K points
(A[lJ, B[lJ),..,,(A[Kj, BIKJ) and fits the M points (x[lj , Y[l])
O
? : i- r . r - s^se
flu
j
-
< x [ ] Y[ ]) in
M
M
^ ^ x ^ t i t *
Zy^St
« T ^ e d V k 1 r U * c ; cfcfu
P
n
the coefficient of X for J = 0,..,,N. The sum of the squares of the deviations is
computed for each polynomial of degree greater than K-l but not greater than N, and
Is stored in the array SGMSQ, i.e., if F (X) is the least squares polynomial of degree L, then
M
SGMSQ[L]
(Y[lJ - F ( x [ l ] ) )
, L = K,...,N .
J
2
L
t = 1
CURFIT will also evaluate the polynomial which it has determined, if the user desires,
for the set of values of the independent variable which it finds in the array Z. The
options available are explained under USAGE.
RESTRICTIONS
(Note: In all that follows, upper c^ase letters refer to formal parameters, while
lower case letters denote the corresponding actual parameters.)
1. In the calling program, the arrays used by CURFIT must be declared to include
the subscript bounds as shown below.
(a) Input Arrays:
real array a,
x, y, w[l:m], z[l:r];
(b) Output Arrays:
real array, alpha, beta [0:n-lj , s, c[0:n] sgmsq[k:n] ;
2.
The values
(a)
(b)
(c)
of the actual parameters must satisfy the following conditions:
l£k<:n<m+k
m a 1
gamma ^ o
3. The user is reminded of the ALGOL-20 restriction regarding labels used as actual
parameters in procedure calls. See page AL.2.U of the ALGOL-20 Manual
for details. The conditions which will cause the procedure to transfer control to the statement which has the label error are:
(a) One or more of restrictions 2 (a), (b) has been violated.
(b) Division by zero was about to be attempted during a calculation. The
usual cause of this is improper or inconsistent data in the input
arrays x and y.
4.
->
V w
/
The arrays a and x must not contain an element in common, or the effect of the
procedure is undefined.
5. CURFIT destroys the contents of the arrays a, x, y and w. Consequently, provision
must be made to save these data (if desired) before CURFIT is called.
METHOD
CURFIT uses the method of orthogonal polynomials, which can be defined recursively
by
P.^t) = 0
P l
The coefficients a
+ ] ft) = (t - on) p
, Pi and s
4
, p (t) = 1 ,
Q
(t) - BiPi-x (t) , i = 0,...,n-l.
t
<l)
are determined such that the nth degree polynomial
t
F
n
(t) =
(t) + SjPi (t) + ... + s p„(t)
SQPQ
B
(2)
minimizes the quantity
62
The coefficients s
t
= L " [ y - F (t )]
r = 1
r
r
n
a
r
can now be used to compute the coefficients of the standard polyno-
mail representation of F
tt
. Suppose that V ^
Pi(t) - V
Then from equation (1), with V
0j 0
r
+ V
1 > 0
= 0 , Vj
r l
t ) l
= 0
is the coefficient of t
t + ... + V j ^ t
1
for, 0 £ i < n
and
0 <: r £ n.
- V
ljr
.!
for all 1, and V ,
t
- a Pt,r
"
t
Hence by equation (2),
a
and we have
F (t) = c
n
0
+
C l
t + ... + c t
n
n
in p ^ t ) , i.e.,
.
we have
V.+i.r
r
Mi-!,!
r
= 0
for r > I,
I
AL.5.GURFIT.3
USAGE
1. Round off errors are reduced if all the abscissas lie in the interval
[-2,2] (see Reference 2). Consequently, a change of scale is introduced by the procedure, using the transformation
X ' [ l J <- (X[lj - XO) / GAMMA ,
where XO and GAMMA must be supplied by the user in accordance with the size of the
data. The appropriate values of these parameters can be determined from the equations
xO = y [max(x[l],a[lj)
3
+
min(x[lj ,a[lj)]
[max(x[lj , a [ l ] ) - min(x[lj , a [ l J ) J .
gamma =
2. The coefficients Qti,$ s
and c ,, as well as the sums of the squared deviations, are accessible to the user as the contents of the arrays alpha, beta, c, s,
and sgmsq, respectively.
lt
3.
it
In addition, there are two built-in print options:
(a)
If orth is true then the value of the least squares polynomial
F (t) is computed using equation (2) for each element of the
array Z. A message to this effect is printed, followed by r
rows of output, each consisting of the number (subscript) J
of the array element, the value z[j] of the array element, and
the value F (z[j]) of the polynomial.
n
n
(b)
If pow Is true, then the value of the least squares polynomial
F (t) is computed using equation (3). The format of the output
is the same as part (a).
n
In some cases method (a) will yield more accuracy then method (b).
However, the corresponding values will usually agree to four or
five significant figures.
TIME AND ACCURACY
With all Internal printing turned off (orth and pow both false). CURFIT
determined an eighth degree polynomial, passing through two points and approximating
eight other points, in approximately one second. The sum of the squares of the
deviations at the eight approximated points was approximately 10$ of the difference
between the maximum and minimum ordinates of the curve.
I
AL.5.CURFIT.4
T
AL.5.ELIPS.1
r
ALGOL Symbolic Library
PROCEDURE SPECIFICATION
PROCEDURE ELIPS (Ml, K, E, TOL, ALARM);
VALUE Ml, TOL; REAL Ml, K, E, TOL; LABEL ALARM;
REFERENCES
1. Algorithm 165, Comm. ACM, April 1963
2. M. Abramvotiz and I. A. Stegun, Handbook of Mathematical Functions, National
Bureau of Standards, 1964, p. 598.
PURPOSE
Given a value of the (complementary) parameter Ml, this procedure computes the
numerical values of K and E, the complete elliptic integrals of the first and second
kinds, which are defined by
First kind:
Second kind:
K(M1)
E(M1)
RESTRICTIONS
1. The user is reminded of the ALGOL-20 restriction regarding labels used as
actual parameters in procedure calls. See page AL.2.14 of the ALGOL-20 Manual
for details.
2. If ML £ 0 or Ml > 1 the elliptic integrals are undefined, and the procedure
transfers control to the statement whose label is the actual parameter corresponding
to ALARM.
3. The actual parameter corresponding to TOL determines the accuracy (and also
the execution time) of the procedure. The size of this parameter is limited by the
relative accuracy of the built-in ALGOL square root routine, and must not be less than
io"
1 2
AL.5.ELIPS.2
METHOD
_
The arithmetic-geometric mean process is used (see reference 2). Starting with
^
the triple (% , ho , Cq ) = (1 ,V ml , 1 - ml) , new values are computed using the iterative
scheme
a
i
=Va
( fi
a
+
b
i-i>
b
i
=V«i-i
During the calculation, the quantity S
b
i-i
c
Wa
i
' i-i
a
"
b
i-i>-
, defined by
l
i
s .
1
is accumulated.
-
j=o
The process stops when the two conditions
'
< TOL
11
and
<
1
TOL
are both met. The desired elliptic integrals are then found using the relations
K = _J]_
2*t
E = K(l -~/ S ) .
a
t
TIME AND ACCURACY
Using a value of TOL = 10~ , nine to ten significant decimal digits were obtained
for both elliptic integrals in approximately ten milliseconds of computation time.
4
c
c
1
AL.5.EXP.1
Standard Function
PROCEDURE SPECIFICATION
real procedure EXP (X); value X; real X;
PURPOSE
EXP computes the exponential function
EtX where E = 2.71828182845...
METHOD
A continued fraction approximation is used.
For further details see page AA-42 of "1604 routines".
RANGE
For X < -161, the result is given as zero.
It is an error if X >160.116998, since in that case EXP(X) will
exceed the largest number representable in the 6-20.
ALARMS
RUN ERROR - EXPu
If X > 160.116998.
TIMING and ACCURACY
The result is produced
in about 1 to 2 milliseconds.
The error is less than 1 -10.
10
o
o
o
r
ALGOL Symbolic Library
PROCEDURE SPECIFICATION
PROCEDURE FREQ (N, A, B , IUL, K, X , KA);
INTEGER N, IUL;
INTEGER ARRAY KA;
REAL A, B , K; REAL ARRAY X ;
REFERENCE
Algorithm 212, Comm. ACM, October 1963
PURPOSE
FREQ determines the frequency distribution of N real variables, the elements of the
vector X , over the interval [A B ] . Each element of X is assigned to one of K equal,
half-open subintervals of [A, BJ, and the frequency of X in the Jth subinterval is stored
in KA[J] .
RESTRICTIONS
1. A is assumed to be the left end-point of the Interval, and hence must be less
than B.
2.
The elements of the vector X must satisfy the inequalities A £ min ( X [l]) <;
max (X[l]) <: B for I = 1,..., N.
3.
The number N of variables being classified must be less than or equal to the
order of the array X .
4.
Upon entry, the array KA is assumed Identically zero.
In the calling program,
the array declaration for the actual parameter ka corresponding to the formal parameter
KA should be:
integer array ka [l : k ] ; where k is the actual parameter corresponding
to K.
METHOD
The interval [A, B] is transformed into the interval [o, K] with unit subintervals
and the elements of the array X classified there by
Y [i] = ( X [i] - A) / ( ( B - A ) / K) for I = 1,...,N.
USAGE
The user has the option of having the subintervals closed at either the upper or
lower end, and must specify his choice according to the following scheme:
If FREQ is
called with IUL = 0, then the lower end-point is included and the upper end-point is
omitted from each subinterval (except, of course, the Kth).
If IUL ^ 0, then the
upper end-point is included and the lower omitted, in each subinterval except the first.
TIME
FREQ classifies approximately one thousand numbers per second.
o
i
o
AL.5.GJR.1
ALGOL Symbolic Library
^
PROCEDURE SPECIFICATION
PROCEDURE GJR(A, N, EPS);
VALUE N, EPS; ARRAY A; INTEGER N; REAL EPS;
REFERENCES
1. Certification of Algorithm 120, Comm. ACM, Jan. 1963
2. H.R. Schwarz, An Introduction to ALGOL. Comm. ACM, February 1962, p. 94
PURPOSE
GJR computes the inverse of the N by N matrix A and stores the resulting inverse
in A.
RESTRICTIONS
1. The actual parameter
a which corresponds to the matrix A must be declared
in the calling program as: REAL ARRAY a [l : n, 1 : n], where n is the actual parameter corresponding to N.
2. An exit, labeled SINGULAR^must be supplied in the main program.
If any pivot
element of the given matrix is less than EPS in absolute value, control will be transferred to the statement which has the label SINGULAR.
'
3. The parameter EPS is impossible to describe in absolute terms; the correct
value to use depends upon the matrix being inverted and also on the precision of the
computer.
If EPS is too large, GJR will not be able to invert the matrix and will
exit to the label SINGULAR, in which case the contents of the array corresponding to A
will be meaningless.
If EPS is too small and the given matrix is ill-conditioned
(close to being singular), the results may be meaningless anyway due to round-off
errors in division.
The following scheme Is suggested:
Use an EPS In the range 1 0
- 5
to 10' . If
7
GJR inverts the matrix and there is any doubt that the inverse is correct, multiply
the original matrix by the calculated inverse and compare the result with the unit
matrix to determine the accuracy of the inverse.
If GJR does not invert the matrix,
decrease EPS (e.g., divide by 10) and repeat until an Inverse is obtained; check
this inverse by the above method.
4.
The order of the matrix to be inverted must not exceed seventy.
METHOD
The Gauss-Jordan direct elimination method, preceded by a pivotal search, is used,
^-s
See K.S. Kunz, Numerical Analysis. McGraw-Hill. 1957, pp. 220-22, 234 and reference 2
for details.
AL.5.GJR.2
USAGE
The user Is warned again that GJR replaces the given matrix by its inverse.
s
Consequently, if e.g., the matrix to be inverted arises as a result of a computation
and is to be saved, provision must be made in the main program to store this array
elsewhere or else print it out before GJR is called.
TIME and ACCURACY
GJR requires approximately 6.5N"**10seconds of execution time, where N is the
order of the matrix being inverted. Typical accuracy is eight significant decimal
digits.
(
r
AL.5.GOOFSTAR.1
r
ALGOL Relocatable Library
PROCEDURE SPECIFICATION
procedure
GOOF.STAR (PROCEDURE.NAME, ERROR.CODE);
value ERROR.CODE;
procedure
PROCEDURE.NAME; string ERROR.CODE;
PURPOSE
GOOF.STAR calls the ALGOL run-error routine which prints the diagnostic error message described in Chapter 6b. This routine may be of
particular use to the programmer writing routines for the ALGOL Symbolic
Library who wishes to use the ALGOL run-error machinery.
RESTRICTIONS
The actual parameter
PROCEDURE.NAME
must not be a function designator;
that is, it must have been declared as a procedure, not as a real procedure.
Boolean procedure, etc.
METHOD
A call of GOOF.STAR causes the ALGOL error routine to print the diagnostic message
RUN ERROR - eeee
where 'eeee' is the actual parameter corresponding to ERROR.CODE. The name of
the procedure must be given as PROCEDURE.NAME so that the error routine can
find the entry to the erring routine and thus print the commands in the user's
program which (presumably) caused the error. The error routine will execute
a HALT, unless an error-recovery switch has been set by RUN.ERROR.
USAGE
Suppose a procedure PIP is used, one of whose parameters is a non-negative
number, DELTA.
The statement within PIP
if DELTA < 0 then GOOF.STAR (PIP, 'PIPl');
will check the validity of the given DELTA and, if there is an error, will call
GOOF.STAR to print
r
RUN ERROR - PIPl
AL.5.GOOFSTAR,2
and the usual diagnostic information. The user may then look in the ALARMS
section of the description of PIP and discover that the PIP1 error resulted
because DELTA was negative. The user may use the procedure RUN.ERROR to
recover from error conditions which invoked calls of GOOF.STAR.
ALARMS
A run-error GOOF will result if the parameter procedure.name is the
name of a function designator.
AL.5.G0SEG.1
ALGOL
PROCEDURE
Relocatable
Library
SPECIFICATION
procedure
GO.SEG
value
I;
(I);
integer
I;
PURPOSE
GO.SEG
positions
substantially
the s e g m e n t
increase
the
tape
running
to
speed
segment
of
a
i.
The
segmented
use
of
this
routine
can
program.
METHOD
is
In
the u s u a l
to be
loaded.
case,
The
some
computation will
initiate
LINK.
At
segment
with
a slew
that
is
time,
loaded.
useful
to segment
slew
slew
a
Thus,
computation.
time
tape
as
from
out
before
a new
segment
(i);
i.
Computation
computation will
it
is
Since
(600
to
carried
statement
GO.SEG
will
be
segment
possible.
cease
possible
it
takes
until
segment
resume
the
to o v e r l a p
tape
time
until
is
the next
positioned
spent
slewing
call
and
to a
N,
it
segment
ms
is w o r t h w h i l e
to
overlap
as
for
the
about
+ 500*|N-M-l|)
M to
will
much
AL.GOSB0.2
O
o
o
AL.5.LINK.l
ALGOL Relocatable Library
PROCEDURE SPECIFICATION
procedure
LINK (I);
value I; integer I;
PURPOSE
LINK loads segment i into core and enters it at the first befiin.
METHOD
IlHK loads „ _
i £,<,«, bulR . f . W . »•*!•, only as „ y vords
M
as there are in the compiled segment.
If the calling program and the
called segment have identical declarations of own scalars and own arrays,
none of these own variables will be disturbed.
Executing LINK causes all non-own variables to be made undefined.
In addition, certain internal variables are reset:
(1) The READ, PUNCH, and PRINT buffers, which may have been
_
set by BUFFER.SET, are reset to the standard buffers
supplied by ALGOL.
(2) All error-recovery switches created by RUN-ERROR are
cleared.
Finally, control is transferred to the outermost begin of the newly loaded
segment; that is, the first statement executed Is always the first statement of the segment.
ALARMS
A run error LINK will occur if
(1)
i < 1, or if
(2)
segment i was not previously dumped as an ALGOL segment.
TIMING
Each call of LINK takes approximately
(600 + 500 * [ N-M-l|)ms
where M is the segment at which the tape is currently positioned and
N is the segment to be loaded.
Running time can frequently be substanti-
ally reduced by use of the procedure GO.SEG.
o
o
o
I
AL.5.LN.1
Standard Function
PROCEDURE SPECIFICATION
real procedure LN (X); value X; real X;
PURPOSE
L N computes the natural logarithm of X.
METHOD
A Chebychev polynomial approximation is used.
For further details see page AA-17 of "1604 Routines",
ALARMS
RUN ERROR - LNLJ,_I
if X< 0.
TIMING and ACCURACY
The result is produced in 1.75 milliseconds.
The error is less than 5, -ll.
0
AL.LN.2
O
O
AL.5.MULLER.I
^
ALGOL Symbolic Library
PROCEDURE SPECIFICATION
PROCEDURE MULLER (Pi, P2, P3, MXM, NRTS, EP1, EP2, SW1, SW2, SW3. SWR, RRT, IRT,
FUNCTION);
VALUE PI, P2, P3, MXM, NRTS, EPl. EP2, SW1, SW2, SW3, SWR; INTEGER MXM, NRTS;
BOOLEAN SW1, SW2, SW3, SWR; REAL PI. P2, P3, EP1, EP2; ARRAY RRT, IRT;
PROCEDURE FUNCTION;
REFERENCES
1. Algorithm 196, Comm ACM, August 1963.
2. Muller, D.E., A Method for Solving Algebraic Equations Using an Automatic
Computer, MTAC, vol. 10 (1956), pp. 208-215.
3. Frank, W.L., Finding Zeros of Arbitrary Functions, JACM, Vol. 5, No. 2 (1958)
pp. 154-160.
PURPOSE
^
MULLER solves a general equation of the form f(z) = 0, where f(z) is analytic in
a neighborhood of the roots. The value of parameter NRTS is the number of solutions to be
determined. Both real and complex roots are found; the Ith root determined is stored
by placing the real part in RRT[I] and the imaginary part in IRT[lJ for I = 1.....NRTS.
Various print options and search techniques are controlled by the Boolean parameters
SW1, SW2, SW3, and SWR, as explained below. No prior knowledge of the location of the
roots is required. Multiple roots are also obtainable, although with less accuracy
than for isolated roots.
RESTRICTIONS
(Lower case letters denote actual parameters, while upper case letters refer to
formal parameters.)
1. The arrays rrt and irt must be declared in the calling program to include the
subscript bounds shown below:
real array rrt, irt[l:nrtsj
2. The procedure function must be declared in the program before MULLER Is called.
It must be able to supply the real and imaginary parts of the value of f(z) for any
desired value of z = x + iy. The declartion of this procedure must be as follows:
procedure function (RE.Z, IM.Z, RE.F, IM.F);
value RE.Z, IM.Z; real RE.Z, i .Z, RE.F, IM.F;
begin ...
M
"(procedure body)
end;
In the above declaration, RE.Z and IM.Z are the real and imaginary parts of the independent variable, while RE.F and IM.F are the real and imaginary parts of the function
AL.i .MULLER.2
evaluated at the point (RE.Z, IM.Z),
(~
Observe that since FUNCTION is a parameter of MULLER, several equations may be
solved in the same program by declaring the appropriate function generator for each
equation with a different identifier. If this technique is employed, the user must
either: (a.) print out the contents of rrt and irt after each call of MULLER; or (b)
supply a different pair of arrays corresponding to RRT and IRT in each call of MULLER.
3. If the equation to be solved is known to have only real roots, swr must have
the value true when MULLER is called.
4. pi, 2 , and 3 are the real parts of three arbitrary starting points. If the
equation to be solved is suspected to have multiple roots, the choice of pi, 2 , and 3
should be such that no one of them is exactly equal to a multiple root. If this restriction is not met, MULLER will not discover that the function has multiple zeros at
this particular root.
5. If the equation to be solved is a polynomial, sw3 should be set true. This
causes the procedure to accept the conjugate of each root found as a root, when applicable (i.e., when the root is not real).
6. If the function has singularities, pi, 2 , and 3 should be chosen such that
none of them is a singular point.
7. epl and ep2 are parameters which specify convergence criteria, while the
value of mxm dictates the maximum number of Iterations to be made in locating any one
root. If neither of the convergence criteria has been satisfied after mxm iterations,
the most recent iterant is accepted as a root and MULLER will proceed to find the next
root (or terminate if nrts roots have been found). The user will receive no warning
that this event has occurred unless sw2 has the value true. When sw2 is true, each
root is printed as. it is found; thus if convergence does not occur, a message to that
effect will be printed along with the value of the last iterant and the value of the
function at that point.
P
P
P
P
P
P
v
—'
METHOD
The algorithm used by MULLER is as follows: given an arbitrary function f(z) = 0
which can be evaluated for any value of z and is analytic in a neighborhood of its
roots, select three arbitrary starting values z , z , z . Find the second degree
(Lagrange) polynomial which passes through the three points (z , f( ) ) , (z , f(z ) )
and (z_, f(z ) ) . Choose z to be the root of this polynomial which lies closer t6
z„. Then drop z, and repeat the process with z_, z_, and *, , etc.
The process stops when any of the following" thr^ee conditions is met:
t
Zl
3
(1)
< epl
z
where z
%
i+
l
is the i-th iterant.
(2) |f(z.)l < ep2 and If (z.)i < ep2 where f(z ) la the value
of the function at the point z
and f (^T is the value of the "modified function"
evaluated at z .
4
l t
i
r
^>
(3) The number of Iterations Is equal to mxm.
The "modified function" is defined as
AL.5. MULLER.3
<> =
f
for r = 2, 3, ...
z
r
r-1
(1)
TT < -j)
z
z
where z is the j-th root found. If f(z) is not a polynomial, it is not possible to
divide out the roots as they are found in order to reduce the degree of the polynomial
and hence the amount of computation. This device is valid, however, if the division
is performed only for those numbers z actually entering the algorithm, I.e., tht points
Zj which are generated during each iteration. Thus, having found r-1 roots, the r-th
root is determined by applying the MULLER algorithm to the equation f (z) = 0, where
f (z) is defined by equation (1). This technique should succeed only for functions
ffz) which have no multiple roots, since f (z) as defined above is indeterminate when
z -> z* , where z* is a root previously found. However, due to the lower accuracy
with wnich multiple roots are determined, they in effect behave like clustered roots
and hence the device has not yet failed.
i
r
USAGE
The region near the starting points (p ,0),
,0), (p_,0) is examined first for
roots; successive roots are then found (usually) in order of increasing magnitude. Thus
it is suggested that starting values reasonably close to the origin be used, unless it
is known that the equation has no roots in that vicinity. In the absence of any knowledge about the solutions of the equations, it has been found (reference 2) that the
starting value pi = -1, 2 = 0, 3 = 1 lead to good performance of the algorithm.
t
P
P
The role of the Boolean parameters will be reviewed here briefly.
(1)
If swl is true, then each iterant of each root is printed, along with
the corresponding values of the function and modified function.
(2) If sw2 Is true, then each root is printed as it is found, along with
the corresponding values of the function and modified function.
(3) If sw3 is true, then the complex conjugate of the root just found is,
when the root is not real, admitted as a root. It is computed directly
from the value of the previous root, rather than carrying out the iterative process for its determination.
(4) If swr is true, then the imaginary part of each iterant is forced to be
zero throughout the iteration, and hence only real roots will be found.
TIME AND ACCURACY
Since it is impossible to adequately describe in general terms the required execution
time and obtainable accuracy for this procedure, several examples are given which indicate
Its performance. All results were correct to ten significant decimal digits.
(1) Using the call
MULLER (1, -1, .5, 50, 10, -10,
false. X, Y, FUNCTION);
ro
all ten roots of the equation
z
1 0
10
-10, false, false, true.
- 1 = 0 were found in six seconds.
(2) The five roots closest to the origin(which all lie on the negative real
axis) of the equation
sin x =
x + 1
x -1
AL.5.MULLER.4
were determined in 44 seconds with the call
£
MULLER (-.4, -5.5, -3.8, 20, 5, -10, , -10, true, true, false, true,
w
0
X, Y, FUNCTION);
(3) The single real root of the equation
xe
= 2
X
was located in seven seconds with the call
MULLER (-1, 0, 1, 20, 1, -10, , -10, true, true, false, true.
to
0
X, Y, FUNCTION);
(4) Fifty-three seconds were required to determine the eight roots of the equation
z
8
+
z
7
+ 3 z + 2z + 3z* - z
6
5
; It - 2z + 1
2
3
using the call
MULLER (-1, 1, 0, 20, 8, -10, -10, true, true, true, false. X, Y,
FUNCTION);
w
ro
r
AL.5.NEVILLE
ALGOL
PROCEDURE
Library
SPECIFICATION
REAL
PROCEDURE
VALUE
W,
iABEL
T
Symbolic
J
N,
NEVILLE
P;
ALARM;
(W,
ARRAY
X,
BOOLEAN
X,
Y,
Y ;
N,
REAL
P,
ALARM,
W;
EXTRAPOLATE) ;
INTEGER
N,
P;
EXTRAPOLATE;
REFERENCES
1.
W.
E.
Milne,
2.
J .
Todd,
Numerical
Survey
Calculus,
of
Numerical
x[o]
,X[N-l]
p.
73
A n a l y s i s ,
McGraw-Hill,
1962, pp.
39-42
PURPOSE
Given
N
abscissas
Y[o] , . . . , Y [ N - 1 ]
forms
the
a
input
range
then
which
P-point
of
abscissa
the
the
end
of
W,
table
the
related
i f
are used
Y[l]
find
the
W < x[o]
transfers
t o ALARM;
table
by
to
and stores
(i.e.,
procedure
corresponding
are
interpolation
and N
f(x [ l ] ) ,
or
W >
control
compute
i n
the
i s
the
=
0,...,N-1
I f
the
the
whose
,
approximate
value
this
value
label
P point: s
values
value
and EXTRAPOLATE
statement
true,
functional
functional
NEVILLE.
X [ N - 1 ] ) ,
to
I
approximate
result
EXTRAPOLATE
to
=
the
corresponding
of
has
i s
1;(W)
W i s
been
the
to
closest
of
procedure
corresponding
by
to
outside
set
the
false,
actual
the
per¬
parameter
appropriate
extrapolation.
RESTRICTIONS
(Note:
by
lower
1.
the
Formal
case
Alarm
ALGOL-20
2.
gram,
n
-
must
be
declared
procedure
1 .
their
are
denoted
i n
the
assumes
that
Consequently,
subscript
3.
The
they
need
4.
entries
The
i n
c a l l i n g
bounds
there
when
must
the
case
letters,
program
as
a
abscissas
not
be
number
the
must
of
table,
n
points
i n
x
and y
are
shown
i n
those
array
be monotone
evenly
are
arrays
include
real
but
by upper
and actual
parameters
label.
See
page
AL.2.14
of
Manual.
The
through
parameters
letters.)
x,
y[0:n-l]
increasing,
the
table
declared
the
having
i n
the
subscripts
c a l l i n g
0
pro¬
declaration
;
i . e . ,
x [ l j
> x [ l - l ]
for
I
=
l,...n
spaced.
points
used
i . e . ,
p
i n
the
interpolation
cannot
exceed
the
number
of
.
METHOD
A
This
v a r i a t i o n
technique
degree
Lagrange
due
i s
to
Neville
equivalent
polynomial
to
which
of
A i t k e n s
f
computing
passes
iterative
the
value
through
the
interpolation
(at
p
the
points
point
of
closest
scheme
w)
to
of
w.
i s
the
used.
(p-l)-st
-
1 ,
AL.5.NEVILLE.2
USAGE
If either of restrictions 3 or 4 are violated the effect of the procedure is undefined. In the event that x[l] = x[j] for I / J, a division by zero will occur and the
execution of the program will be terminated with an EXPONENT OVERFLOW message. Otherwise NEVILLE will attempt to carry out the calculations, but will give meaningless
results. Consequently, the user should take special care to ensure that the restrictions
are.met.
TIME AND ACCURACY
The approximate execution time is
0.6p + 0 6p + 0.05n + 0.6
3
milliseconds, where p and n are the actual parameters which have been defined above. The
accuracy depends upon the behavior of the tabulated function and the number of points
used in the interpolation. Seven to eight significant figures were obtained with n - 20
and p - 5 for the functions SIN(X), COS(X) and EXP(X) over the interval [o,lJ.
^
r
AL.S.NORMRAN.l
ALGOL Symbolic Library
^
PROCEDURE SPECIFICATION
PROCEDURE NORMRAN (MU, SIGSQR, NR, M, SV);
REAL ARRAY NR; INTEGER M; REAL MU, SIGSQR, SV;
REFERENCE
R. W. Hamming, Num. Meth. for Science and Engineering.
McGraw-Hill, 1962, p. 3 8 9
PURPOSE
NORMRAN generates a sequence of M pseudo-random numbers, normally
distributed with mean MU and variance SIGSQR, and stores the sequence
in the vector NR.
RESTRICTIONS
(1)
The starting value SV must be an odd positive eleven digit
number in integer form (no decimal point).
SV is used to supply, the
subprocedure RANDOM which generates uniformly distributed pseudorandom numbers.
(2)
^
The actual parameter which is substituted for SIGSQR in the
call of NORMRAN must have a positive value.
(3)
The desired amount of numbers M must be less than or equal to
the order of the array which is the actual parameter corresponding to NR.
(4) RANDOM is a procedure local to NORMRAN.
METHOD
NORMRAN makes use of RANDOM and the central limit theorem of probability in the following way:
If x [ j j is a uniformly distributed random
number with variance V, then the sequence of numbers
N
NR[l] = ^ +
( E X [ j ] ) / W , I = I,--., M.
J=l
very nearly approximates a sequence of normally distributed random numbers
with mean p, and variance 0
s
being good for N 2 10.
Procedure NORMRAN adds
the x [ j ] in blocks of twelve. Since -1 s x [ j ] £ I for all J, the above
formula reduces to
NR[I] = ^
+
(
J-^ ID l
l
X[J] , 1
= 1
M.
J=l
r
TIME
NORMRAN generates and stores one hundred numbers in approximately 3 seconds.
AL.5.NORMRAND.2
O
O
O
[
AL.5.RANDOM.1
ALGOL Symbolic Library
r
PROCEDURE SPECIFICATION
REAL PROCEDURE RANDOM ( A, B, XO ) ;
VALUE A, B, XO; REAL A, B, XO;
REFERENCES
1. Algorithm 133, Comm. ACM., Nov. 1962
2. R. W. Hamming, Num. Meth. for Sclen. and Engr., McGraw-Hill, 1962, p. 384.
PURPOSE
RANDOM generates the next member of a sequence of pseudo-random numbers from
a uniform (rectangular) distribution on the interval (A, B ) .
RESTRICTIONS
1. The first time RANDOM is called, the starting value XO should be an odd,
positive, eleven digit integer; on subsequent calls in the same program, use XQ=0.
The procedure declares an own variable which saves the current value of RANDOM for
use as a starting value on successive calls.
2. A is assumed to be the left end point of the interval of the distribution,
so that in most applications A should be less than B.
METHOD
The method of congruences is used for the generation:
RANDOM
«- 5 * RANDOM^
(mod 2 ) .
35
If RANDOM is called repeatedly, this results in a sequence with a period of 2
USAGE
As an example of the use of RANDOM, the following short ALGOL program generates
5000 pseudo-random numbers uniformly distributed on the interval (0,1) and stores
the numbers in the vector DATA:
AL
begin
real
array
DATA [l:5000];
Integer I ;
SY
LIBRARY RANDOM
DATA [l] ^RANDOM (0,1, 13543288579) ;
for
I «- 2
step
1
until
5000 do
DATA [i] <- RANDOM (0, 1, 0 ) ;
end
AL.5.RANDOM.2
TIME
Approximately 2.2 seconds are required for the generation of one thousand pseudorandom numbers using this procedure.
o
o
o
ALGOL Relocatable Library
PROCEDURE SPECIFICATION
procedure RUN.ERROR(Ll, ERROR.TYPE, ERROR.PRINTING);
value ERROR.TYPE, ERROR.PRINTING;
label LI; string ERROR.TYPE; Boolean ERROR.PRINTING;
or
procedure RUN.ERROR(Ll, ERROR.TYPE);
value ERROR.TYPE; label LI; string ERROR.TYPE;
PURPOSE
There are certain programming problems in which the programmer is
able to predict that error conditions, as detected by ALGOL at runtime,
may well occur in some data sets.
It is, however, frequently as much
trouble to check a data set for errors as to process the data set.
Thus bad or missing data may lead to subroutine errors, exponent overflows, or address-opcode faults. The use of RUN.ERROR allows the programmer to recover control in such situations, print diagnostic informa^-v
tion, correct for the error, and continue processing.
METHOD
Error conditions detected by the G-21 hardware or by a subroutine
during the execution of ALGOL program ordinarily result In the message
RUN ERROR - eeee
and the termination of the run; the string 'eeee' specifies the type of
error detected.
In the case of errors detected by library procedures,
'eeee' is specified in the ALARMS section of the procedure description;
for other runtime error codes and details concerning the diagnostic
messages, see Chapter 6b.
To recover from such an error condition, the programmer must have
previously specified which error types are to result in recovery and
where in his program control is to be transferred for each of these error
conditions.
The first two parameters in the call of RUN.ERROR give this
information: The value of ERROR.TYPE should be the string 'eeee' to
specify recovery from error condition
eeee.
If error condition eeee
arises, control Is transferred to the label LI, subject to the rules
discussed below. The parameter LI usually should be a simple label and
not the more general form of designational expression; for a discussion
of this see restriction 2.
The parameter ERROR.PRINTING, if included in the call, controls
the printing of the usual diagnostic message for all error conditions.
(See Chapter 6b for a description of this diagnostic message.)
If
ERROR.PRINTING = false, the diagnostics will not be printed; if
ERROR.PRINTING = true, diagnostics will be printed.
ERROR.PRINTING is
used to set the run-time error printing mode switch (-. 42) which is
interrogated by the error recovery machinery each time it is called.
If
ERROR.PRINTING = false, no diagnostics will be printed for any_ routine
for which error recovery is set up. This switch is only changed when a
call of RUN.ERROR is executed which has three parameters. Thus if the
programmer wishes to get only his own diagnostic printing, he may use the
first form of call for RUN.ERROR, with ERROR.PRINTING = false.
If an
error occurs for which a recovery switch was not set, the usual diagnostic
message will be printed. ALGOL initially assumes ERROR.PRINTING = true.
(See also restriction 4.)
Scope of Error Recovery
For each call, RUN.ERROR creates a triple of the form
(LI, ERROR.TYPE, block,level),
hereafter called an error-recovery switch. The scope of these switches is
determined by the block structure of ALGOL.
The use of any error-recovery switch will clear the switch. Thus if
the programmer wishes to re-enable error recovery after having recovered
from an error, he must reset the switch by again calling RUN.ERROR. The
use of one error-recovery switch will not affect the status of any others
which have been set.
Blocks, procedure declarations, and procedure calls may be nested
arbitrarily in ALGOL.
Since It may be convenient to have different recovery
procedures for the same error condition when it occurs in different blocks,
RUN.ERROR keeps the error-recovery switches In a stack. Thus error-recovery
switches created in a given block will not destroy those set in an outer
block, but will merely "push, them down" in the stack. A newly created
switch will be effective for the block in which it is created and for
all blocks and procedure calls nested in that block.
Leaving a block at dynamic level N will pop up the stack, deleting
all error-recovery switches with block.level = N. Calling RUN.ERROR
twice in the same block for the same ERROR.TYPE with actual parameters
LI and L2 will replace the triple (LI, ERROR.TYPE, block.level) by the
triple (L2, ERROR.TYPE, block.level).
Monitor-Detected Errors
RUN.ERROR called with ERROR.TYPE = 'TIMR* will permit recovery
from TIME LIMIT EXCEEDED, PAGE LIMIT EXCEEDED, OPERATOR TERMINATED, and
MACHINE ERROR. The user's program will regain control and will be
allowed an extra 30 seconds of running time. Repeated calls with the
parameter *TIMR' will not give additional intervals of 30 seconds.
One Procedure with Several Error Exits
While some complex procedures have several error exits, the pro^-v
grammer may wish to use the same recovery technique in more than one
case.
Error codes for such procedures are typically of the form 'ABCn',
where n is a non-zero digit.
If an error 'ABCn' occurs, RUN.ERROR
checks for an error-recovery switch of the form ('ABCn',
, ) ; if there
is none, RUN.ERROR will then look for a switch of the form ('ABCO'
, , ).
Qfote that the fourth character is zero, not the letter "0".) Thus the
programmer may handle certain error conditions by special means and
process any other errors by a single general mechanism.
Example:
The error codes for DISC.WRITE are 'RWRl'
'RWRS'.
Suppose the following calls of RUN.ERROR are executed:
RUN.ERROR (LI, R W R 5 )
t
,
;
RUN.ERROR (L3, 'RWRO*);
If an error RWR5 occurs in the block, control will be transferred to LI.
Any other DISCWRITE error will cause control to be transferred to L3.
USAGE
f^-
The following block of ALGOL code could be used to evaluate the function
x
3
+ 1
AL.5.RUNERROR.4
For
various
an
values
exponent
begin
overflow
label
comment:
as
of x,
LI;
real x,
that
a parameter
See
y;
since
2.14
of
f
-4
INFINITE
step
AT
.whenever
NAME(x,
to
RUN.ERROR;
occurrence
we must
declare
of
it
LI
as
is
a
report;
false);
1 until
(xt3
procedure
first
this
f
b e g i n y:=
LI:
library
the
RUN.ERR0R(L1, E X P O ,
go
IS
f
to a p r o e c u r e ,
page
for x:=
out y
occurred:
Note
label.
printing
4 do
+ 1)
y ) ; PRINT
/ x;
K-1D.1Z,
10B,
-4D.4Z,
E» ;
end.of.loop;
NAME
(x); PRINT(< y
IS
f
RUN.ERR0R(L1,
f
end.of.loop:
INFINITE AT ,
-1D.1Z, E > ) ;
f
EXPO );
f
end
end
RESTRICTIONS
1.
any
are
time.
2.
While
evaluated
the
general
values
will
is
more
one
until
a
Not
of
be
than
when
error
all
condition
relevant
the
time
of
not G O O F [ n ] .
to
may
use
ation
of
3.
LI,
but
Run
errors
called,
only
the
simple
so w i t h
in R U N E R R O R
not
permit
recovery
from
LI
be
If
the
error
this
allowed
value
not
evaluated
Since
not
by
is
occurs.
label.
'RWRO
and
at
thus
evaluated
LI
is
actually
according
occurs,
to
and
delayed
the
control
evaluation
work:
+ i) ;
1
control
will
labels
should
to
take
great
are
errors
be
be
transferred
used
advantage
to
for L I ;
of
this
GOOF
the
programmer
delayed
evalu¬
caution.
fatal;
RUNERR0R(L1,
will
called
are
5 do
(GOOF[i] ,
error,
switches
label
time
code w i l l
expressions
should
the
it w i l l
at
1 until
are
actually
resultant
simple
any RWRn
designational
is
ERROR.TYPE
the
1 step
Thus
ERROR,PRINTING
variables
following
i<-
error-recovery
expression,
RUN.ERROR
the
and
RUN*ERROR
designational
for
At
distinct
ERROR.TYPE
transferred
used,
20
f
that
is,
RUNR );
in
f
RUNERROR.
a call
of
the
form:
r
AL.5.RUNERROR.5
4. The switch set by supplying the parameter ERROR.PRINTING is kept
in a single cell (-.42); it does not invoke the stacking machinery applied
to the error-recovery switches.
ALARMS
The message RUN.ERROR - RUNR will result if
1. An attempt Is made to have more than 20 error-recovery switches
set at any time, or if
2.
The designational expression LI is undefined at the time of the
error; this will occur if the actual parameter is a switch element and the
subscript is out of bounds at the time the error occurs.
AL.RUN
ERROR.6
O
O
o
AL.5.SIM.1
ALGOL Symbolic Library
PROCEDURE SPECIFICATION
REAL PROCEDURE SIM (N, A, B , Y) ;
VALUE N, A, B ; REAL A, B ; INTEGER N; ARRAY Y;
REFERENCE
Algorithm 84, Comm. ACM, April 1962
PURPOSE
SIM determines the approximate numerical value of the definite integral of a
continuous function:
B
SIM = |
f(x)dx
RESTRICTIONS
1. The number N of subdivisions must be even.
2.
The values Y[l] of the function must be given for equally spaced values
of the independent variable on the interval [A,B] of Integration.
3. Y[o] = f(A) and Y[N] = f(B)
4.
^
In the program which calls SIM, the actual parameter y corresponding to
the array Y must be declared as ARRAY y[0:n], where n is the actual parameter
corresponding to N.
METHOD
Simpson's well-known formula for numerical integration is used. If
A = x [ o ] , x[l],...,x[N-l], X[N] = B are equally spaced points of subdivision of the
interval [A,B] and Y[l] is the value of the function f at the point x[l] , 1=0,... ,N
then
J
f(x)dx =
A
B-A
3N
<Y[0] + 4Y[l] + 2Y[2] +....+ 4Y[N-1] + Y [ N ] )
TIME and ACCURACY
The approximate execution time required by SIM is
T = 2N*10-
4
where T = time in seconds
N = number of subdivisions.
The accuracy obtained depends very much upon the function being integrated
r
and the number of subdivisions.
o
o
o
AL.5.SIN.1
Standard Function
PROCEDURE SPECIFICATION
real procedure SIN (X); value X; real X;
PURPOSE
SIN computes the sine of X, where X is in radians and may be either
positive or negative.
METHOD
The method is described on page A-l of "1604 routine".
ALARMS
RUN ERROR -* SIN
1^1 ^ ^ 097 i5 \
r or V a l u e s
Deyona cms point tne ai g o n cnm D r e & K f l aown *
TIMING and ACCURACY
The result is produced in 1.08 milliseconds. The relative error is
less than 5 -11.
W
o
o
o
r
AL.5.SLEW.1
ALGOL Relocatable Library
PROCEDURE SPECIFICATION
procedure SLEW(LFT, RECORD.NUMBER,EOF);
value LFT, RECORD.NUMBER;
integer LFT, RECORD.NUMBER; label EOF;
PURPOSE
Reading or writing a tape record 1B delayed by the amount of time
required to position the tape to the specified record.
SLEW enables
the programmer to position a tape while carrying on other computation.
The use of SLEW can thus substantially decrease the running time of a
program which uses magnetic tape.
METHOD
A call for SLEW will initiate a tape motion to record record.humber
of logical file 1ft and will return control to the user's program.
Computation or other input/output operations may then continue until the
execution of a call for DISC.READ or DISC.WRITE with the parameters 1ft
and record.number. At that time, computation will cease until the
tape is positioned and the tape operation completed.
to overlap tape-slewing with useful computation.
Thus It Is possible
If logical file 1ft is
on the disc, no action will be taken and the user's program will continue.
USAGE
The statement
SLEW(3, 40, eof);
will slew to record 40 of the Type 1 RETAP records.
ALARMS
SLEW will exit to the label EOF if RECORD.NUMBER is greater than the
maximum record associated with logical file LFT.
Run-error messages are:
_
SLW1 - LFT is not in the range 2 £ LFT ^ 20
SLW2 - logical file LFT is undefined
AL.5.SLEW.2
TIMING
The time to position a tape to record M, if it is positioned at
record N, is about
( 8 + | M-N - 1 | * 20 ) ms.
The actual time required to instruct the tape unit, which is the time
spent in SLEW itself, is about 2 ms.
Standard
PROCEDURE
Function
SPECIFICATION
real
procedure
SQRT
( X ) ; v a l u e X;
real
X;
PURPOSE
SQRT
computes
the
square
root
of
X,
METHOD
For
details
see
page M - l
of
•'1604
routines"
ALARMS
RUN
TIMING
ERROR
and
SQRT
If X <
0.
produced
In
ACCURACY
The
result
Is
The
relative
error
is
less
1.7
milliseconds.
than
1 -12.
10
o
o
o
AL.6a.l
CHAPTER 6a
ALGOL-20 Card Format and Keypunching Conventions
ALGOL programs should be punched in the following form:
111 1 1 111 11 2 222 2222223333333333...R
Column -> 12 3 45678 9012 3 4 567 89 0 123 4567890123456789
M
Language
I
WHAT
WH
.LOG.
F
OP.
M
Addr,Index;Comment..
ALGOL
AL
ALGOL text..
system
SY
system text.
comment CO
comment,
The teletype TAB table for these language fields Is as follows:
Tab ->
1
2
3
4
5
Language field
i
^-v
AL
4
7
10
13
16
WH
4
15
20
24
40
SY
4
CO
no tabs - tabs are taken as characters.
tabs after the first are taken as characters and scanned,
Tabs taken as characters are printed as '=' on the LP-12.
A blank language field (columns 1 and 2) is Interpreted as AL or
WH, as determined by the most recent appearance of AL or WH in the
language field. A blank language field on the first card is interpreted
as AL.
System cards give special instructions to the ALGOL translator.
The system instructions are described In Chapter 4.
Comment cards are printed as part of the translation listing but
are otherwise ignored. They may be freely inserted for purposes of
documentation.
Normally, the programmer may use columns 4-72 for his ALGOL program;
however, there is a system statement with which he may change the righthand margin from 72 to any column between 40 and 80, as described In
Chapter 4. The columns beyond the right margin may be used for comments,
etc.
r
AL.6a.2
The translator will ignore all columns to the right of a double
vertical bar (||).
This allows the programmer to use the rest of the
card for comments.
(Double vertical bars in strings will not invoke
this convention.)
In ALGOL-20, certain constructions may not be spilt between the
end of one ALGOL text card and the beginning of the next, since the
translator always supplies an imaginary blank column between the righthand margin of one card and column 4 of the next:
(1) An identifier may not be continued from one card to
the next. The implied blank will terminate an identifier which ends at the right margin of the card.
(2) The combination characters
:=-,>-,<-,=
8L
8R
8F
must be punched with the two characters in adjacent columns of the same
card.
In addition, alphanumeric strings may not be split between two cards.
One reason for this restriction is to provide better error recovery if a
quote is accidentally omitted. A long alphanumeric string instruction in
a READ, PRINT, or PUNCH statement may simply be closed by " ', "
(quote comma) after the last character of the string punched on the card
and reopened with another quote on the next card.
The ALGOL program may be punched in any format the programmer desires,
subject only to the above restrictions. There may be one statement per
card or a single statement extended over many cards or many statements on
a single card. Thus, a consistent indentation rule which aligns each end
with its begin can be used to advantage to show clearly the structure of
the program.
(See also Chapter 6c.)
CHAPTER 6b
ALGOL-20 Error Messages
Translation Errors
The ALGOL-20 translator prints numerical error codes to indicate
syntax errors in the source program.
The translator prints the error
code just below the last card image it has scanned, with an arrow
V
pointing to the last character scanned on this image. Since each card
is scanned once from left to.right, the 't* pointer will generally be
ahead (i.e., to the right) of the actual error.
Errors are broadly categorized as Phase I errors (0 through 69),
Phase II errors (70 through 95), miscellaneous errors (96 through 99),
Subscan errors (100 through 109), and System errors (110 through 125).
System errors are those occurring on SY cards. Subscan and Phase I
errors are purely syntactic and are discovered in tht process of scanning
the source program cards. Phase II errors are discovered at a later
stage in the translation process when the actual machine code of the
object program Is generated.
The miscellaneous errors are those which
Indicate a possible problem within the translator. Any listing containing such an error should be brought to the attention of the User
Consultant or a member of the Computation Center staff immediately.
The translator attempts to "recover" from each error if possible,
so that many independent errors may be found in one pass through the
computer. However, any Phase I error as well as errors marked with * in
the error list will cause all succeeding Phase II errors to be ignored.
To call the programmer's attention to the fact that subsequent Phase II
errors are being ignored, the translator will print "NOTE 6" (see the
section on notes below) as Phase II is turned off.
Any error prevents execution of the compiled program.
Notes
The Algol-20 translator prints notes on the program listing to call
the programmer's attention to syntactic constructions which are acceptable but questionable, or constructions which are possibly caused by an
error. Notes do not prevent execution of the compiled program.
Translation Errore
Phase I Errors (Each of these errors terminates Phase II.)
0: The program does not start with begin.
A statement starts with an illegal character or an illegal reserved word.
2
A statement starts with an identifier followed by an illegal character.
3
In an expression an operand was expected and was not found.
4
In an expression a binary operator was expected and was not found.
(Possibly caused by a semicolon missing after the preceding statement.)
5: A " ] " does not have a matching "[".
6: An array element has been used illegally.
7: A ":" has appeared incorrectly.
8: A V
or ":=" has appeared incorrectly.
9: A " ) " does not have'a matching "(".
10: A "," has appeared incorrectly.
11: then has appeared without if.
12: else has appeared without then.
13: Characters are still in the stack after a ";" or an end.
14: A procedure statement is followed by other than end, else, or
15: for is not followed by an identifier.
16: The for variable is not followed by a "«J' or ":=".
17: step has appeared without for.
18: until has appeared without step.
19: while has appeared without for.
20: do has appeared without for.
21: go to is not followed by an identifier or " ( " or .If.
22: go to if...then...is not followed by else.
23:
24: An obscure error in a go to statement.
25: An Impossible error after begin. ("J-" is not the second element In the
stack. See Error 98.)
26: own is followed by something other than <type>.
27: An array declaration does not specify subscript bounds.
28: The identifier list of a declaration is not followed by a .....
29: switch is not followed by an Identifier.
30: The identifier of a switch declaration is not followed by a ' V or ":«".
31:
32: procedure is not followed by an identifier.
33: A procedure identifier is not followed by " ( " or
01
34: A formal parameter list is not followed by " ) " .
35: The " ) " following a parameter list is not followed by a
36: The identifier
tlfler list in a spec
specification is not followed by a
" in
in an
an identifier
identifier list.
37: An identifier did not follow the ","
38: The illegal construction "then if" has occurred.
39: A switch with more than one"~subscript position has been used.
40: The value part of a procedure declaration was not followed by a ";".
ti.ti
AL.6b.3
41
42
43
44
45
46
47
48
49
The name of a permanent subroutine (such as "SIN") is not followed by "(".
There is an extra "," or else a missing ":" in an array declaration.
More begin's than end's have occurred when the end-of-file is reached.
Impossible - see E7ro"r 98.
max or min is not followed by "(".
In an array declaration the Identifier list is not followed by "[".
Array specifier has subscript bounds, which it should not.
library is not followed by <type> or procedure.
Phase I Errors
50:
51:
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
A reserved Input/output word is not followed by " ( " .
A format list element starts with an illegal character. (Should be "<"
TI .IR or "$"
II6H or identifier).
J J k~ i c i
\
or "-»"
is missing: i.e., a replicator was expected but not found,
for is missing after "$".
~*T is not followed by "$" or an identifier.
" ) " or
Is not followed by " ) " or
A name statement or format statement Is not followed by end, else or ";"
A replicator is not followed by " ( " or "<".
"<" or V* is followed by an illegal character.
An integer is followed by an illegal character.
A format instruction is not followed by ">" or ",".
An illegal prefix to a numeric primary has been used.
An illegal numeric primary has been used.
"." appears in a numeric primary in a read statement.
In a numeric primary, E, F or S is not followed by an integer.
X
Phase II Errors
*70:
71:
72:
73:
74:
75:
76
77
78
(format and name statements) (Each of these errors terminates
Phase II.)
(Only those errors marked
turn off Phase II.)
A reserved word which is not yet available has been used.
A label has been used but not defined. (The name of the label is
printed prior to this error message)
An identifier has been used but not declared.
An identifier has been declared twice in this block.
An identifier in the value list Is not a parameter.
An identifier which has been used as a procedure has not been declared to
be one.
A subscripted identifier has not been declared to be an array or switch.
The program is too long.
A procedure identifier which Is not a function designator has been used
in an expression.
79:
82:
83-
An identifier which has been used as a switch has not been declared to
be one.
An array identifier has been used without subscripts.
Too many index variables have been declared.
A label or array or switch has been called by value.
An identifier in a specification list is not*, parameter.
In a procedure declaration a parameter la not specified.
In a procedure declaration a parameter is specified twice.
A procedure, switch or label appears on the left of a ":=" or ".J .
1
*87:
88¬
89
*90:
*9l:
92-
More than 100 relocatable library procedures have been declared.
A constant has been used in place of an identifier, e.g., 33[k] .
A subscripted for variable has been used (this is not yet available in
ALGOL-20).
The next-command pointer is less than the base of the program.
Miscellaneous Errors
96:
97:
98:
99:
A possible translator error - bring listing to Janet Fierst at the
Computation Center.
Impossible: bring your listing to A. Evans at the Computation Center.
Same as 98.
Subscan Errors
100:
101:
A card column contains an illegal combination of punches.
Too many abcons or adcons have been used (numerical constants and
alphanumeric string constants).
102: Too many decimal points appear in a number.
103: Too many "«"B appear in a number.
104: An error has appeared in a parameter delimiter comment: ")<any string
not containing:>:(".
105: An illegal bar ( "I" ) variable has been used.
106: A constant has been used which is too large to fit into a real variable.
107: A V
is followed by something other than "+", »-», or <digit>.
108: A string goes over the end of a card.
*109: The symbol table has been exceeded.
110:
111:
112:
113:
114:
AL.6b.5
System Statement Errors
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
An abcon system statement has occurred after code has been compiled.
An abcon system statement has requested more space than there is In
user memory.
An illegal SY card has occurred. (This may be caused by a LIBRARY card
after the symbolic library has been released.)
The library procedure nesting exceeds 5.
WHAT has been called after it has been released.
An illegal segment statement has been used.
An SY LIBRARY card has asked for a routine not in the symbolic library.
A library procedure declaration has named a routine not in the relocatable
library.
Notes
Note 1:
Note 2:
Note 3:
Note 4:
Note 5:
Note 6:
Note 7:
Note 8:
Note 9:
end comment convention was used on preceding card. T h a t is, everything was ignored up to
end, or else.
A function designator has been used as a procedure statement.
- an arithmetic or boolean expression, the construction if...then if
In
s occurred. This is syntactically illegal but unambiguous,"aid Is"
has
-refore accepted b y the translator,
the
rithmetic (boolean) (designational) expression has been used
An ar
,„ (boolean)
f u ^ ^ (designational) expression
where a simple arithmetic
should have been used.
- a designational expression, the construction if...then if has
In
curred? This is syntactically illegal but un^mbigu^s"."
Phase II has been turned off.
The construction if...then for...do...else... which is legal in
ALGOL 60 but illegal in ALGOL 62 has been used.
TAB appears as a character.
Fifty errors have been found on a single card; compilation has been
terminated.
T
RUN ERRORS
During its execution, an ALGOL-20 program will call upon various
run-time subroutines. Since there are usually restrictions placed
upon the use of these routines, there is a mechanism provided to warn
the user when the restrictions have been violated.
It is the violate
ion of these restrictions which is referred to as "run error".
The user may receive his warning in either of two ways:
If he
takes no action otherwise, an error message will be printed out as part
of his output listing which will identify the error and the part of
the program in which the error took place. The run will then be
terminated.
On the other hand, however, the programmer may provide for
a "recovery procedure" by calling on a subroutine named RUN.ERROR.
If
he does this, an occurrence of the error will cause a transfer to a
statement in his program which he has designated.
The programmer may
then provide error recovery as he deems appropriate.
If the programmer
has provided for error recovery from a given error type, he has the
option of either getting or not getting the normal diagnostic printout.
See Chapter 5.RUNERROR for a description of the recovery procedure.
The normal error printout consists of the two lines
RUN ERROR - eeee
COMMAND IN ERROR - ccccc
followed by fourteen lines of diagnostic output. Here ccccc is the (octal)
location of the command which caused the error (or the command which
called the subroutine in which the error was detected) and eeee is a
mnemonic error code. By comparing ccccc with the octal addresses printed
on the left side of the compilation listing, the programmer may determine
the particular statement or declaration whose execution caused the error.
Error codes for library procedures are given in the ALARMS section of the
procedure description in Chapter 5. All other error codes are listed on
the next page. The fourteen lines of diagnostic information refer to the
seven commands before the faulty one, the faulty command, and the six
commands following.
On each line, there are four fields:
the location,
the command in octal, the command in semi-mnemonic form, and the contents
of the word whose address is in the command.
This information is useful
to anyone familiar with G-20 machine coding in analyzing the error. It is
of interest to the average user only in that it may be shown to the User
Consultant.
AL.6b.7
Error
Code
Meaning
ADRP
address--opcode
CFLG
command
EXP
EXP
EXPO
exponent
LN
LN
RADl
upper
flag
(X)
(X)
error
called
with
<
lower
in a b o u n d
pair
in
an
declaration
declared
arrays
READ
An
has
error
The
160 . 116998
overflow
RAD2
SIN
X>
c a l l e d w i t h X <. 0
array
data
fault
card,
exceed
occurred
(see
argument
available
in
reading
space
a
below)
to S I N
or
COS
exceeds
8t21
SQRT
SQRT
TIMR
monitor
XtAl
X = 0 and A * O
XtA2
A * LN
XtA3
X £ 0 and A not
When
message
error,
and
one
1)
an
will
an
error
be
$$
the
detected
preceded
arrow
of
is
(t)
by
pointing
following
- CARD READ
a
by
(X)
the
auxiliary
of
IMPROPER
NUMBER
than
read
An
integer
the
data
mark
has
4)
ILLEGAL
SYMBOL
A
are
have
in
has
been
character
(i.e.,
This
card
in XtA
"RUN
ERROR-READ
containing
the c o l u m n
not
been
the
has
been
11
the
number,
reached:
to
read
i.e.,
more
data
"deck".
attempted
been
image
to
scan
before
an
read
"E"
a
or
executed
to
has
been
scanned;
e.g.,
points,
+ or
- signs,
or
number
card.
found.
which
cannot
a digit,
scanned
error
has
from a card
ill-formed
has
the
attempted
statement
primary
|s
valued
column,
too m a n y d e c i m a l
10
XtA
messages:
program
"W"
in
subroutine,
An E n d - o f - F i l e
A
XtA
160.116998
read
characters
3)
>
X<0.
errors
in
erroneous
cards
NO C A R D R E A D
(X)
the
the
2)
detected
printout
to
called with
by
message
be
part
of
" + ",
a
is
numeric
a
number
or
V')
instruction.
suppressed
by
the
suffix
"N",
o
o
o
AL.6c.l
CHAPTER 6c
Printing of the Compiled Program
Consistent Indentation of each level of nesting of subordinate and
compound ALGOL constructions is useful in writing a clean, readable
program.
The maximum possible indentation of the program as punched onto
cards is limited by the width of the card.
However, the printed image
is 21 columns wider than the card, so the system statement INDENT has
been provided to let the programmer take advantage of the extra printer
width to get more indentation of the printed source program. Normally,
the compiled ALGOL code is printed in the format
PRINT columns |l23|4567 |8
Contents
|
CARD columns
|l23|
12113,14]15...83j84...1041L0...1201
5
|blank|addressjblankj
text j blank | comments|
j*---."!
| 3
7
88|
Using the system statements INDENT and RIGHT MARGIN (see Chapter 4 ) , the
programmer may change the number of card columns scanned as text and
^
also may change the print columns in which this text appears. In general,
the compiled code is printed as follows, where K stands for the indent
constant and RM stands for the right margin:
PRINT columns
112314567 18. ... 121 13 .. . 14-HC| 15-Ht... 11+K4*M| 12-HU«M.. .32+RMJ 33+RM..
Contents
|
CARD columns
|l23|
]blank|address|
blank
|
|4
text
|
RM|
blank
| comments |
JRM+1
The address printed is that of the first instruction generated by the line of
ALGOL text.
r
88|
o
o
o
AL.6d.l
CHAPTER 6d
r
Privileged Identifiers
In addition to the reserved identifiers, ALGOL-20 includes a set
o f
"privileged" identifiers which have built-in meanings. These
Identifiers can be used with their built-in meanings without being
declared; they are, in effect, declared by the translator in a block
head outside the outer-most block of the program.
Therefore, if the
programmer does not wish to use one of these identifiers in its
privileged meaning, he may simply ignore the fact that it is privileged and declare and use it as he would any non-reserved identifier.
If a privileged identifier is redeclared within an inner block, it
resumes its privileged meaning as soon as the end of that inner block
is passed.
The currently available privileged identifiers in ALGOL-20 are
described below. As additional privileged identifiers become available,
they will be described on sheets which can be added to this chapter.
ACC
ACC is a symbol denoting the accumulator, which may appear on the
left side of an assignment statement. Thus
ACC:= A[i, j, k+3];
will fetch an array element to the accumulator. ACC is of particular use
in setting the accumulator before executing a piece of WHAT code. This
mechanism should always be used when accessing array elements or formal
parameters called by name for use in WHAT code. No error will be detected
if ACC appears other than on the left side of an assignment statement, but
such uses will usually cause spurious results.
CLOCK
CLOCK is an integer-valued function designator which is called with
a single parameter. The value of "CLOCKCO)" is the elapsed time in
seconds since the Name-Time card was read. "CLOCKCV)" is the elapsed time
in seconds minus the integer value of the parameter V, also in seconds;
i.e.,
CLOCK(V) = CLOCK(O) - V
Example:
A:
STARTTIME «- CLOCK(O) ;
B: ELAPSE <- CLOCK(STARTTIME) ;
This will store in ELAPSE the elapsed time in seconds between passing
label A and passing label B.
DAY
MONTH
YEAR
DAY, MONTH, and YEAR are built-in variables of type logic which are
set by the translator to the four-character alphanumeric string representations of the current day, month, and year, respectively. The format is
best defined by example: On the 9th of April, 1962, we have
DAY = 'u.09u'
MONTH = 'APRu'
'62UU'
YEAR =
The statements:
NAME ( DAY, MONTH, YEAR ) ; PRINT (<12A, E>) ;
i
would print a line containing:
|
|
09 APR 62
DEBUGPRINT
DEBUGPRINT is a procedure with an arbitrary number of parameters which
!
prints the values of Its parameters in a simple rigid format.
Its para-
meters may be any arithmetic or Boolean expressions. Arithmetic values are
printed in the format <+.ilZL> ; i.e., in scientific floating point nota|
tion with 11 significant figures. Boolean values are printed as:
TRUE for true
+.0000O000000 4O0 for false
w
Values are printed four per line; the first value printed by each call of
DEBUGPRINT starts on a new line.
AL.6d.3
_
EPSILON
EPSILON is a built-in real constant, whose value Is the smallest
positive number which can be represented In the G-21.
ft *\
EPSILON = 8
„ 1.274473528903 -57
tt
HALT
HALT is a parameterless procedure. Execution of a HALT statement
terminates the run-time execution of the program and returns control to
the monitor. Thus, executing a HALT statement is equivalent to letting
control pass the final end of the program.
EXAMPLE:
1£ X > ,„8 then HALT ;
INFINITY
INFINITY is a built-in real constant, whose value is the largest
positive number which can be represented in the G-21.
INFINITY = ( 8
- 1 )* 8
» 3.450873173389*69
PAGES
PAGES is an integer procedure with no parameters.
Its value is the
total number of pages which have been completely printed since the job
card was printed.
If the printer is positioned to the page which contains
the job card information, the value of PAGES is zero.
PAUSE
Executing this parameterless procedure invokes the monitor PAUSE
mechanism, J27, in the usual way. When the program is subsequently
restarted, PAUSE will return to its calling point. For further details,
see the description of |27 in the Monitor Description: THEM THINGS.
AL.6d.4
PRINT
PRINT is a procedure with one parameter which controls the output
of printed information on a teletype.
character is a one.)
(Note the spelling:
the third
The compilation listing and execution-time output
are always printed on the on-line printer, if a positive number of pages
is requested on the Job Card.
PRINT sets a monitor switch which deter-
mines whether execution-time output will also be typed on the teletype
which originated the program.
If the program did not originate at a
teletype, then PRINT will simply be ignored.
PRINT (1) : Sets switch so output will be on the teletype and printer.
PRINT (0) : Sets switch so output will not be on the teletype, only on
the printer.
The status of the switch can be changed as often as desired; when an ALGOL
program begins execution, it is set to PRINT (0) unless zero pages have
been requested on the Job Card, in which case, it is set to PRINT (1).
TIME
TIME is a real procedure with no parameters, whose value is the time
of day in seconds, starting at midnight.
AL.6e.l
CHAPTER 6e
Machine-Dependent Features
1. Octal Constants
An octal (base 8) constant may be used in any context in ALGOL-20
where a decimal number is allowed; i.e., as a primary in any arithmetic
or logic expression. Octal constants have the following syntax:
<octal diglt>
<octalian>
: : = 0 j l | 2 | 3 | 4 | 5 | 6 | 7
:: = <octal digits | <octalian> <octal d i g i t s
<signed octaliarS ::
B
<octalian> | + <octaliari> | - <octalian>
<left-justified octal constants :: =
<right-justified octal constants :: =
8L <octaliari>
8R <octalian>
<floctaliari> :: = <octaliari> | <octalian>.<octallan> | <octalian>. |
.<octalian>
<power of 8> :: = <signed octalian>
ro
floating octal constants :: =
8F <floctalian> | 8F <power of 8> |
8F <floctalian> <power of 8>
<logical octal constants :: = <left-justifled octal constants j
<right-justified octal constants
<octal constants :: = floating octal constants | <logic octal constants
Despite this syntax, the translator does not treat the digits 8 and 9 in
octal constants as erroneous but will interpret them as 1 0 ) and l l ) ,
g
respectively.
g
Thus 8R495 « 8R515.
Local octal constants (8L and BR) are considered to be of type logic
and so are always accessed in logic mode. Floating octal constants (8F)
are considered to be of arithmetic type, and are always accessed in
arithmetic mode.
The character-pairs 8L, 8R and 8F are treated by the translator as
single entities and must be punched In adjacent columns of the same card,
without intervening blanks.
AL.6e.2
ting
The
value
the
floctalian
priate
power
integer.
of
of
For
a
floating
as
8,
an
treating
l o
10
«
value
prefixing
of
d i g i t s .
logic
word.
2.
8L4
=
String
Since
multiplying
number
which
follows
it
the
10
by
concatena-
by
the
as
an
is
determined
approoctal
0
and
to
eleven
the
is
=
octalian
then
octal
leftmost
8L7
j u s t i f i e d
8L3,
a
of
require
the
constant
enough
zeros
concatenated
d i g i t s
bit
octal
and
to
give
stored
as
thirty-three
leftmost
octal
eleven
a
32-bit
bits
for
is
lost.
digit
" S - f l a g " .
Constants
as
constants
of
G-20
in
strings
an
internal
word
in
G-2 0
internal
the
abcon
not
ALGOL-20
region,
character
a l l
of
have
constants
1
the
=
may
and
is
for
blank
four
Such
a
characters
string,
may
be
converted
to
r i g h t - j u s t i f i e d
as
a
(YJ )
logic
is
1
octal
zero,
in
a
a
32-bit
constant.
the
used
set
logic
Since
following
string
f
be
used
«
":
=
f
in
f
uuuA
any
f
context
in
which
octal
constants
allowed.
Examples:
1.
i f
2.
ABCD
(The
3.
A
1
value
i f
(This
that
is
nextchar
(xA
tests
the
if
xA
then
r
stringval
<¬
8L377
of
the
expression
8R377)
=
whether
A
(8R377
=
1
the
parentheses
are
'A )
1
the
value:
= uuA
1
than
stored
treated
a
same
LA
more
program.
characters
•A
String
and
(right)
number
the
Alphanumeric
constants
number
determined
9*8T-5
left
This
representation,
Thus,
a
=
(suffixing)
octal
the
is
8t8
8Fll„-5
by
octal
constant
example:
8F
The
octal
in
example
2
i s
'A^uu )
1
then
right-most
needed,
then
which
character
since
is
of
without
always
x
is
them,
false.)
"A .
1
the
Note
meaning
are
_
3.
Bit-Manipulation Operations
In addition to arithmetic, Boolean, and designational expressions,
ALGOL-20 snytax includes "logic expressions" which perform bit-by-bit
logic operations on 32-bit G-20 logic words. A logic expression may
include any of the following operands:
1.
Logic constant:
octal constant or string constant
2. Variable, simple or subscripted, of type logic
3.
Function designator of type logic
4.
Boolean primary (and, therefore, any Boolean expression in parentheses)
5. Arithmetic primary (and, therefore, any arithmetic
expression in parentheses)
A Boolean primary used as a logic operand is interpreted as one of
the two 32-bit logic words:
8R 37777777777 « 32 one bits for true, or
8R 0
= 3 2 zero bits for false.
Each kind of logical operand (except number 5 above, arithmetic
primary) will always be fetched from memory with a "logic access", rather
than a "numeric access"; for example, a CAL command will be used to fetch
a logic variable Into the accumulator. When a logic variable or function
designator forms the left-part of an assignment statement, then an STL
command will perform the assignment. Therefore, an assignment statement
of the form
<logic variable> <- Arithmetic express iori>
will truncate the absolute value of the expression modulo 2"*^. An STL
command is also used for any temporary store of a logical subexpression
< u
<
<
\
<
U<
1
1
I
t
(except an arithmetic primary) within a complete logical expression.
An
of the followin
thr
1
expression:
- i (complement logic:
unary)
A (extract logic: binary)
V (unite logic: binary)
ical
1
Each of these operators performs the same operation simultaneously
and independently In each of the 32-bit positions of its operand(s). If
a bit = 1 represents the Boolean value true while a bit = 0 represents
false, then the logic operators - i , A , and V can be considered to perform
the Boolean operations - i , A , and V , respectively, in each bit position.
The operators +, -, *, and / may also appear in a logic expression.
Each of these operates in the usual way, considering its logical operands
(except for arithmetic primaries) as 32-bit integers.
The complete syntax for logic constructs is given below:
<logic constants :: = <string constants | <logic octal constants
<logic primary> :: = <logic constants | <logic variables | <logic function> )
<Boolean primary> | «logic expressions) |
<aTithmetic
primary>
<logic factor> :• = <logic primary> | - i <logic primary>
<logic ternS :: = <logic factor> | <logic term> A <logic factor>
<simple logic expression :: = <logic term> | <slmple logic expressiorS V
<logic term>
<logic expression> :: = <simple logic expressiorS | <if clause>
<simple logic expressiorS else <logic expression
4.
Half Variables
A variable of type half behaves exactly as one of type real except that
It contains fewer digits (about 6 instead of about 12). Since half
variables take only one location in the machine and real variables take two,
it is possible to save storage space by declaring large arrays to be of
type half instead of real, if the loss of significance can be tolerated.
5.
Index Variables
Simple variables of type index are stored in G-20 index registers.
Eventually, efficient code will be compiled for index variables, using the
G-20 index register commands. For the present, however, index is of
interest only in connection with machine language assembly code ("WHAT")
within an ALGOL-20 program.
variables.
Index variables behave exactly as do integer
j
r
CHAPTER 6f
Segments
ALGOL programs which are too long to fit into core memory may be
divided into subportions, called segments. Each segment will be stored
on tape after it is compiled and may then be called into core memory
as it is needed.
Each segment area on tape holds 10240,, words. If a segment contains
more than this, it will be stored on successive segment areas. (The
number of such areas needed is the second parameter to the SY Segment
statement.)
A segment is an ALGOL-20 program which includes a SEGMENT system
statement.
Each segment must be a complete ALGOL-20 program; that is,
it must have a set of matching begin's and end's and declarations of all
Identifiers which are used in the segment.
After a segment has been compiled (i.e., after the end which matches
the first begin is found), the code which has been compiled and any
^•v
relocated subroutines will be written onto tape as the specified segment.
ALGOL will then continue reading cards, expecting to find another program;
this program may also be a segment. Compilation terminates after a program
which is not a segment is processed; control is then transferred to the first
statement of this program.
If in a program (or segment) the statement LINK(i) appears, segment i
will be loaded and control will be transferred to its outermost begin.
It is convenient to be able to communicate data in core memory between
different segments. However, linking from one segment to another involves
exiting from the outermost block of the current segment, thus making all
variables declared in the segment undefined.
To overcome this, the same
block of storage locations is used in all segments for own arrays and own
scalars. Thus, if identical declarations of own arrays and own scalars
are made in different segments, all these values may be transmitted from
one segment to another. All other scalars and arrays are undefined when a
new segment is loaded; these may be communicated by means of the procedures
r
DISC.WRITE and DISC.READ.
O
o
o
AL.6g.l
CHAPTER 6g
ALGOL DISC/TAPE ROUTINES
CONTENTS
I.
II.
III.
IV.
V.
Introduction - Files and Records.
Logical File Types.
A.
Preassigned Logical File Types.
B.
Addressing Disc/Tape Files via Logical File and Relative
Addresser Tables.
The Binary File Routines
DISC.READ and DISC.WRITE.
A.
Parameters and Call.
B.
Examples of Use.
C.
An Algorithm for Buffered Reading.
The AND.FILE Routine.
The Hollerith File Routines.
A. Introduction.
B.
Primary vs. Secondary Files.
C.
Opening and Closing Hollerith Files.
D.
Card Image Pointer.
E.
Parameters and Call of HOLLER- Routines.
F.
The Operation of HOLLER.IN.
G.
The Operation of HOLLER.OUT and HOLLER.OVER.
AL.6g.2
I.
INTRODUCTION - FILES AND RECORDS.
ALGOL-20 includes a set of relocatable library subroutines for
storing binary and Hollerith data in the G-21*s disc memory or on
magnetic tapes. This chapter explains these routines and their
relationship to the AND system and to certain parts of the Monitor.
A knowledge of AND is assumed, although no knowledge of the Monitor
is required to understand this chapter.
Disc and tape space is divided Into segments of consecutive
storage called files. A file in turn is generally subdivided into
a number of sections with similar (or identical) format, called
logical records. The user may subdivide a file into logical records
in any way he pleases; for example, the logical records could be of
varying lengths, or they could all have a fixed length (e.g., 237 words
each).
Files are recorded on disc and tape in units of 320 words,
called physical records or blocks.
If the length of the logical
records is not a multiple of 320 words (the physical record size),
then transmission of logical records to and from disc and tape files
requires the use of buffer areas in core memory to pack and unpack
logical records into physical records.
The G-21 Monitor and the
AND System use a standard format for
files of 80-character "card images" of Hollerith information.
A file
with this standard format is called a "Hollerith File", and always
consists of 21-word logical records. Each logical record contains 84
characters, packed four-characters-per-word"; the last four characters
form a Hollerith serial number, the kth image in the file having serial
number k (except see the AND System description, page 4.407 of the User's
Manual, for the numbering system beyond card 9999).
The G-21 Monitor includes a "card read routine", |16, which can
unpack 21-word logical records of a Hollerith input file from a 320-word
internal buffer area in core memory.
The relation of |16 to ALGOL pro-
grams is explained more fully in Section VB.
i
AL..6g.3
Each file is assigned space on disc or tape in units of complete
blocks, i.e., in multiples of 320 words.
The space allotted to a file
has a fixed length and therefore an end, called its physical (or binary)
End-of-File.
("End-of-File" will be abbreviated to "EOF" in this chap-
ter.) Disc/Tape routines will detect an attempt to read or write beyond
the physical end of a file, and will notify the programmer of the End-ofFile condition, for example, by returning through a special exit. Thus,
a program which processes a file may use the EOF condition as a signal to
transfer out of the main processing loop.
The routines for reading and writing disc and tape may be divided
into two sets:
the binary file routines, and the Hollerith file routines.
1) Binary File Routines:
DISC.READ, and DISC.WRITE.
These routines are very efficient for moving large quantities of
data between ALGOL arrays in core memory and bulk storage (i.e., disc or
tape files).
They assume no logical record structure for the file, but
read and write in units of complete 320-word physical records. Files
read with DISC.READ and written with DISC.WRITE will be referred to as
"binary files", since no logical record structure is assumed by these
routines; however, such binary files could contain any mixture of binary
numbers and Hollerith strings arranged by the programmer (see the examples
in Section III).
The programmer using the binary file routines may wish
to provide buffering in his ALGOL program to pack and unpack logical
records which are not a multiple of 320 words in length;
see Section III
for a complete discussion.
2) Hollerith File Routines:
HOLLER.IN, HOLLER.OUT, and HOLLER.OVER.
These routines allow ALGOL format READ, PRINT, and NAME statements to
be used to read and create Hollerith files. For example, the HOLLER.IN
("HOLLERith INput") routine sets switches in the Monitor to cause "E" and
"W" instructions in READ statements to take successive images from a
selected Hollerith File on disc or tape. Then the full machinery of NAME
and READ statements may be used to scan the images character-by-character
AL.6g.4
for Hollerith strings and numbers, to convert them to binary, and to
store them into ALGOL variables. The HOLLER.OUT ("HOLLERith OUTput")
and HOLLER.OVER ("HOLLERith OVERwrite") routines provide the corresponding ability for creating Hollerith files, image-by-image, using NAME
and PRINT statements. HOLLER.OUT appends images to the end of a file,
while HOLLER.OVER is used to alter images of an existing Hollerith file.
Since all Hollerith files have identical format, a file created by
HOLLER.OUT (or -.OVER) may subsequently be edited by the AND System.
See Section V for a complete explanation of these routines.
Since a Hollerith file is composed of 21-word logical records,
^~
= 15.24 card images fit into each physical record; a file with binary
320xB.
length of B blocks can contain at most i( ^
) -
card images. However,
a Hollerith file may contain fewer than this maximum number of images.
The end of Hollerith information Is indicated by a Hollerith End-of-File
image which normally appears immediately after the last image currently
in the file.
A Hollerith End-of-File image is distinguished by the presence In
columns 1 and 2 of two
lower-case dollar signs , G-20 character codenl65,
This code is the G-20 internal representation of the (+,
8, 9) punch
combination which always appears in columns 1 and 2 of a job card; thus,
each iob card serves as an EOF card for the preceding lob in the card
reader. The rest of the EOF image contains a message indicating which
routine wrote it there: for example, the EOF image:
SS ALGOL END OF
\
*
.
, reader
, ,is
FILE is written by HOLLER.OUT. An EOF image from the card
n
blank except the two lower-case dollar signs.
It is usually important to have an EOF image in a Hollerith file
since, for example, the Monitor card read routine
16 checks for the
Hollerith EOF image but not for the physical EOF. Hence, if the programg
y
~*
mer is usine the EOF condition to terminate his program when it reaches
mer
usi g
^
,
, ,
the end of reading a Hollerith file, he must have an EOF Image in the
•
alwa s contain EOF ima es- those
P
t
u
AL.6g.5
created by HOLLER.OUT will have an EOF image if the programmer
"closes" the file - see Section V.
The disc/tape routines DISCWRITE, HOLLER.OUT, and HOLLER.OVER
allow an ALGOL user to write directly onto any of his AND fil
any files which are listed under his man number in the AND Di
However, these routines never change the dump count of the file
written. Therefore, a user who writes files using these ALGOL
and saves the file for later runs must be aware of the possi
which the dump count protects AND users) that ail AND files m
back one or more days as a result of hardware failure. To p
against this possibility, the programmer may want to keep his o
count somewhere in the file, increment the count when he writes
file, and check for the value he expects before reading or wri
the AND file is written only once and thereafter is only read,
only as a temporary ("scratch") file during a run, then there
for a dump count.
The user should also note that the AND files are stored n
the disc but also on two permanently-mounted magnetic tapes. It
approximately three minutes of computer time to traverse one of
tapes end-to-end. An ALGOL user who attempts to access more th
file on the same tape can easily waste huge amounts of compute
moving ("slewing") the tape back and forth between files. On t
hand, any number of files on disc can be accessed "randomly",
without wasting time slewing. Note: a file is on disc if it
Block Number in the Directory is less than 21000. Anew AND i
will shortly be available to force a file to be created or d
the disc rather than onto one of the AND tapes; the programmer
therefore have a convenient way of avoiding severe tape slews du
the ALGOL disc/tape routines.
AL.6g.6
II.
A.
LOGICAL FILE TYPES.
PREASSIGNED LOGICAL FILE TYPES.
The ALGOL disc/tape routines refer to particular files by an integer
value between 1 and 19 called the Logical File Type ("LF Type").
Some
of the Logical File Types have been pre-assigned to certain fixed files
in the CIT system:
e.g., the AND Scratch Area. However, any of the 19
Logical File Types may be assigned to any permanent AND file for the
duration of the run, either by the AND System or by the ALGOL library
procedure AND.FILE. Normally, a user should use AND to set up all LF
Types for all files he will need, before the ALGOL translator is called
to compile and execute his program.
In some cases, the user will need to
assign AND files to LF Types during his ALGOL run; the library-procedure
AND.FILE is provided for this purpose (see Section IV).
The LF Types currently pre-asslgned are as follows:
LF Type
1
Meaning
Current effective beginning of AND Scratch
Area.
Length
(blocks)
Length
(card
images)
(see below)
(see below)
Physical beginning of
AND Scratch Area
3072
46811
3
Retap 1 Records
(same as AND Scratch
Area).
3072
46811
4
Retap 2 Records
(the second half of
AND Scratch).
1536
23405
5
Retap 3 Records
(on a permanently
mounted system tape)
6
Comp Center Records
(NOT available to
user, unless specifically allocated by CC
staff!).
s10000
* 152381
1
AL.6g.7
^
In some circumstances (specifically, the execution of a "RUN,
AND, ..." instruction) the AND System moves the effective beginning
of the AND Scratch Area past the end of information already in Scratch.
AND defines Logical File Type 1 to be the effective beginning of the
Scratch Area when AND loads and executes the ALGOL system.
Logical File
Type 2, however, is always defined as the fixed physical beginning of
the Scratch Area.
It is recommended that LF Type 1 rather than LF Type
2 be used to refer to AND Scratch so that "recursive" AND runs can be
performed without changing the operation of the ALGOL program.
B.
ADDRESSING DISC/TAPE FILES VIA THE LOGICAL FILE AND RELATIVE ADDRESSER
TABLES.
The correspondence between a particular LF Type and actual block
addresses on the physical input/output devices is established by two
tables in the Monitor:
the Logical File table, and the Relative Addresser
table. The ALGOL programmer is thereby removed by two levels of generalized (or "symbolic") addressing from the physical input/output devices.
The process of finding a block on the physical device can be visualized
by the following picture:
AL.6g.8
The LF Type is used to select an entry in the Logical File Table
which specifies:
(1) a Relative Addresser Type ("RA Type") and (2)
the first block of the file, relative to the first block of the region
defined by the RA Type. This RA Type is used in turn to select an
entry in the Relative Addresser Table, which specifies:
(1) the (logical)
number of an actual i/O unit and (2) the first physical block number of
that RA Type region on that unit. This addressing process can be summarized by the following ALGOL statements:
to find block number B of
the file with Logical File Type LF.TYPE, the Monitor uses:
U <- 10.UNIT [RA.TYPE [LF.TYPE]] ;
P ^PHYSICAL.FIRST.BLOCK [RA.TYPE [LF.TYPE]]
+ RELATIVE.FIRST.BLOCK [LF.TYPE] + B
where U is the logical i/O Unit number, and P is the physical block
number on that unit. The logical unit number U is converted to a physical
I/O unit number through another Monitor Table to achieve flexibility in
the use of the physical tape drives; this last logical-physical correspondence is irrelevant to the programmer, however.
The Relative Addresser Table (discussed on page 14 of the Monitor
"|routine" write-up "THEM THINGS") provides a global allocation of space
on tape and disc, generally the same for every program run. The Relative
Addresser Table is changed in two circumstances:
(1) The Computer
Operations staff may change the global allocation of space on tapes and
disc, or may convert the entire operation to tapes when the disc is
"down"; and (2) a user may specify a "User Tape" on his job card, replacing
one (or more) of the standard system Relative Addresser entries by
entries pointing to his own magnetic tape, only for the duration of his
run.
If a User Tape replaces a Relative Addresser Type to which a
Logical File Type is assigned, then the meaning of the Logical File Type
and the length of the file change correspondingly, but only for the
duration of the run.
AL.6g.9
III.
A.
THE BINARY FILE ROUTINES: DISC.READ AND DISC.WRITE.
PARAMETERS AND CALL.
DISC.READ will read information from disc or tape into an array
in core memory; DISC.WRITE will write the contents of an array in core
memory out onto disc or tape. These routines allow the user to move
binary and Hollerith information in bulk between core memory and
disc/tape files. Their parameters are as follows:
DISC.READ(NWDS, FIRST.LOC, LF.TYPE, BLK.NO, EOF.EXIT);
DISC.WRITE(NWDS, FIRST.LOC, LF.TYPE, BLK.NO, EOF.EXIT);
Here:
NWDS = Number of machine words to read or write.
FIRST.LOC = An array element which is the ALGOL name of the
first word in core memory to read or write.
LF.TYPE = Logical File Type (explained in Section II).
BLK.NO = Number of the first 320-word block to be read or
written (the first block of the file has block
number 0 ) .
EOF.EXIT = Label through which the routine will exit if the
physical End-of-File is reached during the operation.
Starting at the block number BLK.NO of the tape/disc file with Logical
File Type LF.TYPE, the routines will read or write as many blocks as
are needed for the number of words NWDS.
DISC.READ reads into core
memory exactly NWDS words, where NWDS Is not necessarily a multiple of
320.
DISC.WRITE will write enough extra words (generally "garbage") to
complete the last 320-word physical record. These routines initiate
direct input/output transmission between core memory and the tape or
disc unit; there is no buffering.
Attempting to read or write beyond the physical End-of-File will
cause the routine to complete the operation up to the End-of-File, and
AL.6g.10
then exit through the EOF.EXIT label.
If an AND file assigned to a Logical File Type (by AND.FILE, or
by the AND system) belongs to a programmer different from the man making
the run, then this LF Type will be marked "read only".
Calling
DISC.WRITE (or HOLLER.OUT, or HOLLER.OVER) to write on this file will
cause a run error; thus, a user can write only on his own files.
Both
DISC.READ and DISC.WRITE print the same run-error messages, as follows:
RUN ERROR - RWRl:
The specified Logical File Type has not been
pre-assigned or assigned by AND or by AND.FILE.
RUN ERROR - RWR2:
A negative number of words has been called for.
RUN ERROR - RWR3:
The FIRST.LOC address lies outside user's
memory.
RUN ERROR - RWR4:
LF.TYPE is out of range:
1 * LFTYPE 5 -19.
RUN ERROR - RWR5:
DISC.WRITE has been asked to write on a file
which is marked "read-only".
B.
EXAMPLES OF USE.
Assume the following declarations:
real array. x[o: 20, 1:100];
integer array
l[o 1000];
:
logic array
L[l:300];
Then the subroutine call:
DISC.READ (4200, x[o,l], 1, 23, EOF);
reads 4200 words into the X array in core memory from the file with Logical
File Type 1 (the AND Scratch Area), starting from block 23 of this file.
Each element of the real array X occupies two machine locations and
X[0,l] is the first element of X; therefore, this call will exactly fill
the X array. There is no check in DISC.READ (or DISC.WRITE) for overflowing an array; if this call were changed to read more than 4200 words,
the extra words would be stored into locations beyond the end of the X
array, presumably clobbering another array.
AL.6g.ll
^
Similarly, the entire I array may be written on records 40 through
43 of AND Scratch by the procedure call
DISC.WRITE (1001, l[o], 1, 40, EOF);
Since each integer variable is stored in one G-21 memory location, 1001
words are needed for the 1001 elements of the array.
A little more than
three blocks are needed for this WRITE operation; the fourth block will
be filled up with whatever happens to be in memory in the locations
following l[l000] .
These routines may be used to read or write alphanumeric strings;
such strings should be stored in core in arrays of type logic. Each
word of the string contains four characters. Thus, the call:
DISC.WRITE (300, L[l] , 1, 0, EOF);
will write a string of 4 x 300 = 1200 characters from the array L.
C.
AN ALGORITHM FOR BUFFERED READING.
In all the above examples, each logical record read or written was
assumed to start at the beginning of a physical record.
If the logical
records contain significantly fewer than 320 words, however, this simple
assignment of logical to physical records is wasteful of both time and
space on tape or disc.
If disc/tape space is important and if the
logical records are short, the user should Include buffer routines in
his ALGOL program to pack and unpack logical records from each physical
record. The buffer area would be an ALGOL array whose length was a
suitable multiple of 320.
For example, the procedure declaration below describes the algorithm
for buffered reading from a binary file. The algorithm reads BUFF.SIZE
blocks at a time into a buffer array:
BUFF [l:320*BUFF.SIZE].
Note that BUFF is a "dynamic own array" (see page AL.2.14 of ALGOL-20
Manual); if this algorithm is used in an ALGOL-20 program, a numerical
AL.6g.12
value must be substituted for BUFF.SIZE before the program Is compiled,
or else BUFF must be declared globally to the procedure. Although the
formal parameter A in BUFFERED.READ Is a logic array, an array of any
type may be substituted as an actual parameter; however, if a real
array Is substituted, then the actual parameter substituted for N must
be doubled.
AL.6g.13
procedure
BUFFERED.READ
value
N,
integer
comment
logic
Each
process
r e f i l l
into
EOF
C a l l i n g
Type
of
LF.TYPE,
logic
array
BUFFERED.READ
variables
the
the buffer
i s
BUFFERED.READ
number
LF.TYPE;
call
empties
physical
A,
E O F . E X I T ) ;
LF.TYPE;
N,
words
(N,
A[l]
internal
from
the
exits
to
BUFFERED.READ
and b u f f e r
-LF.TYPE,
and moves
own
logic
array
own
integer
if
LF.TYPE
label
with
pointer
to
the
EOF.EXIT;
next
of
a
BUFF,
Logical
logical
logic
record
array
DISC.READ
F i l e
logical
Type
i s
A.
i s
I f
called
LF.TYPE.
record
of
I f
N
this
to
the
obtained,
EOF.EXIT.
LF.TYPE
the
the
array
with
before
the
the
A [ N ]
buffer
encountered
label
moves
,
f i l e
A;
<
0
beginning
first
n-word
i n i t i a l i z e s
of
block
logical
0
the
of
record
the
of
record
Logical
the
F i l e
f i l e ;
begin
begin
I
BUFF
PT,
<
[l:320*BUFF.SIZE]
BLK.NO;
0
integer
I ,
;
ULIM;
then
BLK.NO
<- 0
;
PT * - 3 2 0 * B U F F . S I Z E
end
i n i t i a l i z a t i o n ;
4-1;
MORE:
ULIM
for
*-min
I
(N,
«- I
A[l]
320*BUFF.SIZE
step
1
<-BUFF[PT
comment
ULIM
begin
<
move
N
PT
end
ULIM
;
do
l ] ;
words
comment
BLK.NO
of
PT)
u n t i l
N word
moved
or
buffer
empty;
then
BUFF
DISC.READ
end
+
u n t i l
-
i s
empty
(320*BUFF.SIZE,
4-BLK.NO
PT
< - PT
go
to
+
and more
words
BUFF[l]
abs
are
needed;
(LF.TYPE),
BLK.NO,EOF.EXIT);
BUFF.SIZE;
320*BUFF.SIZE;
MORE
r e f i l l ;
«- PT + max
BUFFERED. READ
(N,
(
0)
;
) ;
HINT UBRAJtT
CARNEQIE-MELLM HNIVERSITY
AL.6g.14
IV, THE AND.FILE ROUTINE
The relocatable library procedure AND.FILE allows an ALGOL program
to define
a Logical File Type as a particular AND file.
AND.FILE .is
called with the following parameters:
AND.FILE(USER, FROG, LF.TYPE, BUFF.LOC, ERR.EXIT);
where:
USER = The AND "User" number for the file, an eight character
alphanumeric string; this string may appear either as
an 8 character string constant (e.g., 'PH33WW01 ) or as
1
the name of the first of two successive elements of a
logic array which contains the string as value (see
example below).
PROG = The AND "Program" number of the file (not including, the
dump-count).
LF.TYPE = The Logical File Type to be associated with this AND
file; LF.TYPE must lie in the range:
1 s LF.TYPE 3 19.
BUFF.LOC = An array element which is the first element of a
vector of at least 320 words.
ERR.EXIT = A label to which AND.FILE will exit if any of the
parameters are improper or if the designated AND file
does not exist in the AND Directory.
The effect of calling AND.FILE is to look up the AND file under
(USER, PROG) in the AND Directory, and assign it to Logical File Type
LF.TYPE.
The 320 locations starting at BUFF.LOC are used as a buffer
to read the AND Directory; after the call of AND.FILE, this space is
available for other uses.
It is important to observe that AND.FILE reads but never writes
on the AND Directory; thus, the AND Directory will never be changed as
a result of execution of AND.FILE. This implies that:
(1)
the file being looked up must already exist; it will not be
created by AND.FILE If it does not exist;
AL.6g.15
(2) operation of AND.FILE will never change either the physical
(I.e., binary) length of the AND file, or the most-recentaccess date in the Directory, or the Dump Count of the file.
In general, a run using the AND system will be required to create an
AND file or to increase its length. There Is an AND instruction
"CREATE" for this purpose.
The user is warned that If he accesses an AND file only in his
ALGOL program via the AND.FILE procedure, never in AND itself, then
the latest-access-date for the file will never be updated.
As a re-
sult, the file will eventually be "frozen", i.e., moved to a history
tape and deleted from the current AND records. On the other hand,
setting up a Logical File Type during an AND run does update the access date of the file in the AND Directory; hence it is generally
preferable to set up L.F. Types during the AND run rather than to use
AND.FILE.
An example of a call of AND.FILE would be:
^
Integer array
BUFF [1:320] ;
label GLUGJ
logic array
USER[1:2] ; integer I, PROG.NO;
:
name (I -*2(USER[I]) , PROG.NO.) ;
read (<£, 8A, 8D» ; comment read user number and program number
from a data card;
AND.FILE(USER[1] , PROG.NO, 12, BUFF[1] ,GLUG) ;
GLUG:
PRINT (< NO SUCH FILE EXISTS', 2E» ; HALT ;
(
This program will read an 8 character user number string (e.g.,
'S236JP01') and an integer program number from a data card, and look
AL.6g.16
up the corresponding file in the AND Directory.
If the file exists,
it will become Logical File Type 12; if not, the statement labeled
"GLUG" will be executed.
The 320 words BUFF[1]...BUFF[320] will be
used to read the AND Directory.
If AND.FILE is called to look up an AND file under a man number
differing from the man number appearing on the Job Card, then the corresponding Logical File Type entry will be marked "read-only". Calling DISC.WRITE, HOLLER.OUT, or HOLLER.OVER to write on a read-only
AND file will cause a run error; thus, a user can use the ALGOL disc/
tape routines to write on his own AND files only.
AND.FILE checks carefully the validity of its parameters. Any
of the following errors will cause it to print an appropriate message
and exit to the label ERR.EXIT without defining the Logical File Type.
A subsequent attempt to operate on this Logical File Type with one of
the other disc/tape routines will cause a run error.
The error con-
ditions detected by AND.FILE are:
1. Usage number is improperly formed or not in AND directory.
2.
Program number is out of range or not in the AND directory.
3. Designated file is empty (contains 0 words) and can therefore be neither read nor written.
4.
Logical File Type does not satisfy IS L.F. Type £ 19.
5.
Selected AND file is on a tape which is temporarily unavailable.
6.
AND instruction DONT has not been executed, so the AND
Directory cannot now be read by this CP.
See AND System
Write-up.
7.
Attempt has been made to access another man's file which is
marked "secret". See AND System Write-up.
AL.6g.17
r
V.
THF HOLLERITH FILE ROUTINES
A.
INTRODUCTION
The DISC.READ and DISC.WRITE routines move binary and Hollerith
information in bulk between core memory and disc/tape files. The
"HOLLER-" routines, HOLLER.IN, HOLLER.OUT, and HOLLER.OVER, on the
other hand, provide buffered input and output of Hollerith files using
ALGOL format READ, PRINT, and NAME statements.
Calling HOLLER.IN selects a Hollerith file as the source of card
images for READ statements; each subsequent execution of an "E" or "W"
instruction will read the next image from the selected file into the
format read buffer, where it can be scanned character-by-character.
Similarly, HOLLER.OUT (or HOLLER.OVER) will cause each "E" or "W"
format instruction in a PRINT statement to output columns 1 through
80 of the 120-column print buffer plus a sequence number in columns
81 to 84, as the next image of a selected Hollerith output file.
^
HOLLER.OUT (and - .OVER) supply consecutive integer serial numbers,
equal to the ordinal numbers of the Images in the file. HOLLER.OUT
appends images to a file, while HOLLER.OVER may be used to alter
images in the middle of an existing Hollerith file.
B.
PRIMARY vs. SECONDARY FILES
When an ALGOL program begins execution under the G-21 Monitor,
there is always one Hollerith input file and one Hollerith output
file; these are referred to as the "primary" Input and output flies,
respectively.
The primary input file may be a teletype input file,
an AND file, the AND Scratch Area, or a physical deck in the card
reader, for example.
The primary output file may be the LPT2 printer,
a teletype output file, or both.
The HOLLER- routines designate
auxiliary input and output files, referred to as "secondary files".
When an "E" or "W" format instruction is executed in a READ
statement, the ALGOL format routine calls the Monitor card read
AL.6g.t8
routine
("|16")
to supply a Hollerith card image,
j16 has implicit
parameters which indicate whether the image is to come from the next
physical card in the card reader, or from the next
21-word logical
record in a particular Hollerith file on disc or tape.
case, J16
In the latter
transmits to the (84-character) ALGOL READ buffer* the card
image which is the next
area in core memory.
320-word buffer,
then
21-word logical
record in a
320-word input
buffer
If this image was the last complete image in the
|16
automatically reads the next
320-word
block
from disc or tape into Its buffer area, in anticipation of supplying
the next image.
(Note:
this description has omitted some details which
are unnecessary to an understanding of the HOLLER- routines; further
information on Monitor routines may be found in Section 2.3
of the CIT
User's Manual.)
The function of HOLLER.IN is to set the source parameters of
|16
to take Hollerith images from a particular file. Calling j16 either
implicitly with "E" or "W" format READ instructions, or explicitly in
machine language with WHAT code will read successive images from the
file selected by HOLLER.IN.
It should be remembered that any routine
in the user's program whose effect Is to read "cards" will ultimately
call |16,
and will therefore get images from a secondary file if
HOLLER.IN has been called.
Similarly, when the ALGOL format routine executes an "E" or "W"
instruction in a PRINT statement, or a "W" instruction in a READ
statement, it calls the Monitor Hollerith output routine ("|ll") to
transmit the print line to the primary and/or a secondary output file.
The function of HOLLER.OUT (and -.OVER) is to set the secondary destination parameter in |11
to a particular secondary output file. The
*Note: the "ALGOL READ buffer", part of the format READ mechanism
of ALGOL, contains exactly one 84-character card image to be scanned
by format instructions; it should not be confused with the 320-word
input buffer area used by |16 to unpack 21-word logical records from
320-word disc/tape blocks.
AL.6g.19
r
images sent to a secondary file are collected in a 320-word buffer in
core memory; when this buffer is filled, its contents are automatically
written onto the next physical block on tape/disc. Even if the programmer calls |11 directly In WHAT code, |l1 will transmit the print
line to the primary and/or secondary output files as determined by
HOLLER.OUT (or -.OVER).
On the other hand, ALGOL run-error messages,
page headings, and output from DEBUG.PRINT are transmitted only to the
primary output file, never to a secondary output file.
C.
OPENING AND CLOSING HOLLERITH FILES
The process of selecting a Hollerith file with HOLLER.IN, HOLLER.OUT,
or HOLLER.OVER will be referred to as "opening" the file; the "deselection" of a file will be referred to as "closing" that file. Closing a secondary output file writes the last 320-word block from the
core buffer onto the file on disc or tape.
The user of HOLLER.OUT or
HOLLER.OVER is cautioned that the system does not automatically close
a secondary output file when the ALGOL program terminates.
The user
must call HOLLER.OUT(O) or HOLLER.OVER(0), as appropriate, to close
the file and write out the last block, or he will lose up to 16 card
images.
Because input can be read from only one source at a time, there
can be only one open input file at once:
either the primary input
file, or a secondary file selected by HOLLER.IN.
On the other hand,
the same output line may be transmitted simultaneously to more than
one output file, so one secondary output file (selected by HOLLER.OUT
or HOLLER.OVER) may be open simultaneously with the primary output
file, if the user so chooses.
D.
CARD IMAGE POINTER
The Hollerith card read routine J16 has an input card image
pointer which contains the serial number of the next card image to be
read from the current file (unless the input file is a physical card
deck, in which case the card image pointer is undefined); each call
r
AL.6g.20
of |16 increments this pointer automatically.
The Hollerith print
routine J11 has a corresponding output card image pointer which contains the serial number of the next card image to be output to a
secondary output file, but is undefined if no secondary output file
is open. Note that the output card image pointer is associated only
with a secondary file, and has no necessary connection with the serial
number of the primary output file.
If a secondary output file is
open, then each call of |11 converts the value of the image pointer
to 4 Hollerith characters and stores it as the serial number in columns 81-84 of the image (note:
this serial number is also stored into
columns 81-84 of the print line sent to the primary file); then the
image pointer is incremented by 1.
HOLLER.IN sets the input card image pointer when it selects a
new input file; first, however, the previously selected file is
closed, and the previous value of the card image pointer is saved in
a pointer temporary associated with the previous LF Type. Similarly,
when HOLLER.OUT or HOLLER.OVER selects a new secondary output file,
it closes the previous file and saves the previous value (if any) of
the output card image pointer in the pointer temporary associated
with the LF Type of the previously selected secondary file, before
setting the output card image pointer to a new value.
The programmer
can reselect ("reopen") any secondary file which was selected earlier
in the run, either for reading or writing, in such a way as to restore
the card image pointer to the value saved in the pointer temporary for
that LF Type.
It is important to note, however, that there is only
one pointer temporary for each LF Type, used for saving both input
and output card image pointers.
This makes it convenient to read
through a file until a certain image is found and then start rewriting
the file from that image on.
In addition to the internal pointer temporary mechanism just
described, there is provision in the call of the HOLLER- routines for
!
AL.6g.21
storing and setting the Input and output card image pointers using
ALGOL variables designated by the programmer.
When an ALGOL program begins execution, the pointer temporaries
for all LF Types (except perhaps 0 and 1) are initialized to 1.
Calling AND.FILE to assign a particular LF Type to an AND file
initializes the pointer temporary of that LF Type to 1.
It is possible to have the same file, with the same LF Type, open
for both Hollerith input and Hollerith output, simultaneously. Furthermore, the same file can be assigned (by the AND system or by AND.FILE) to more than one Logical File Type. This gives the user great
flexibility in processing several different parts of the same file at
once. However, the user should avoid doing such an operation on a
file which is on a tape rather than on the disc, or machine time may
be wasted on long tape slews.
It is convenient to think of the primary input file as Logical
File Type = 0. For example, when the primary input file is closed by
HOLLER.IN and a secondary input file becomes the card image source,the
input image pointer for the primary file is saved in the internal
pointer temporary associated with LF Type = 0. Calling HOLLER.IN to
open LF Type = 0 will reselect the primary input file, after closing
the previously selected secondary input file. LF Type = 0 has no
relation to the primary output file, which cannot be opened or closed
by the HOLLER- routines.
E.
PARAMETERS AND CALL OF HOLLER- ROUTINES
The HOLLER- routines may have one or two parameters, as follows:
HOLLER.IN(LFT) ;
or
HOLLER.IN(LFT, POINTER) ;
HOLLER.OUT(LFT) ;
or
HOLLER.OUT(LFT, POINTER) ;
HOLLER.OVER(LFT) ;
or
HOLLER.OVER(LFT, POINTER) ;
In each case, the formal parameters could be specified by:
value
LFT ; integer
LFT, POINTER ;
AL.6g.22
LFT is generally the Logical File Type of the file to be opened for input (HOLLER.IN) or output (HOLLER.OUT or HOLLER.OVER); see the detailed
description of each routine below.
Any arithmetic expression may be
substituted for the LFT parameter.
The meaning of the parameter POINTER depends upon the value of
LFT:
1 s LFT s 19: Pointer = the serial number to which the card image
pointer will be initialized in the secondary file with
LF Type = LFT.
In this case, any arithmetic express-
ion may be substituted for the parameter POINTER.
If
the POINTER parameter Is omitted, then the card image
pointer will be initialized instead to the value of the
Internal pointer temporary associated with LFT.
LFT = 0:
POINTER is a variable which will be set equal'to the
previous input or output card image pointer, i.e.,
the pointer in the file which is being closed; this
same pointer value is also stored in the internal
pointer temporary associated with the LF Type being
closed.
In this case, only a variable, either simple
or subscripted, may be substituted for POINTER.
If
POINTER is omitted, then the card image pointer will be
stored only in the internal pointer temporary.
The programmer may wish to find out the serial number of the next
image to be output to, or read from, an open secondary file; notice
that closing and immediately reopening the same Logical File Type will
have no effect other than saving the current image pointer in POINTER,
if the parameter is present in the statement which closes the file.
The user may also wish to skip about in one file, which means that the
internal image pointer from a preceding file closure will be lost on
a following closure; if the user saves his own copy of the pointer in
POINTER when he closes the file, he may reopen the file later at this
serial number by using POINTER as parameter.
AL.6g.23
F.
THE OPERATION OF HOLLER. IN
A call of the following
form:
HOLLER. IN (LFT); or HOLLER.IN(LFT, P O I N T E R ) ;
opens for Hollerith input the file with LF Type = L F T , after closing
for input the file which w a s previously open*
The following steps are
petformed:
(1)
Hie previous value of the input card image pointer is
assigned to the internal pointer temporary for the
LF Type of the file previously open for
(2)
If LFT = 0,
selected)
input.
(i.e., the primary input file is being
then the previous card image pointer is also
assigned to the variable POINTER
(if the POINTER para¬
meter is p r e s e n t ) .
(3)
The card image source is set to the file with LF Type = LFT:
1 s LFT
A
19: opens a secondary input file,
LFT = 0
(4)
and
: reopens the primary file.
The input card image pointer
(i.e., the serial number of
the first image to be read from the newly opened file)
is
set equal to the value of the pointer temporary for file
LFT, unless LFT is > 0
selected)
(i.e., a secondary file is being
and the parameter POINTER is p r e s e n t ; in the
latter c a s e , the input card image pointer is set to the
value of POINTER.
Thus,
the ALGOL programmer can always
"get hold of
image pointer of a secondary file by executing:
11
of the input card
HOLLER.IN(0,
HIS.POINTER)
to close the secondary input file and store the pointer in the ALGOL
variable HIS.POINTER.
The user cannot
"get hold of" the card image
pointer for the primary f i l e , since this file may be a physical card
deck for which the pointer is undefined.
On the other hand,
if the
user has arranged it so that the primary file is a particular AND
file or one of the files which have preassigned LF T y p e s , then the user
AL.6g.24
can assign the same file a LF Type and select it as a secondary file
with HOLLER.IN; he can then effectively "backspace" and reread such
a primary input file.
Whenever the Monitor card read routine J16
transmits a Hollerith
EOF image to the ALGOL READ routine or directly to the user, a switch
is set in the Monitor; if |16
is called to provide another card image
after this EOF switch is set, the Monitor will terminate the program.
However, calling HOLLER.IN with L.F. Type = 0 not only closes the
secondary file, but also clears this |16 EOF switch. Therefore, the
user can read and detect the Hollerith EOF image in a secondary file
(by testing for the first two characters being 8R165), close the file,
and continue reading images from the primary file or open another
secondary file.
HOLLER.IN may produce any of the following run-error messages:
RUN ERROR - HINl
LFT < 0 or LFT > 19
RUN ERROR - HIN2
Attempt to close a secondary input file when
there was no secondary file open for input.
RUN ERROR - HIN3
Attempt to read from a file which was not
predefined or defined by AND or AND.FILE.
RUN ERROR - HIN4
Attempt to set the image pointer to a negative
card number or beyond the physical End-of-File.
G.
THE OPERATION OF HOLLER.OUT AND HOLLER.OVER
A call of the form:
HOLLER.OUT(LFT); or HOLLER.OUT(LFT, POINTER);
will close the secondary file (if any) which was previously open for
Hollerith output; if LFT > 0, it will then open the secondary file
number LFT for Hollerith input.
If 1 5 LFT * 19, then the following steps are performed:
(1)
If there was previously a secondary output file
open for Hollerith output, then it is closed in
the following manner:
AL.6g.25
(a) The output card image pointer is assigned
to the internal pointer temporary of the
LF Type previously open.
(b) A Hollerith EOF image is placed after the
last image appended to the file (but the card
image pointer is not incremented, so if the
file is later reopened at this point then the
EOF image will automatically be overwritten by
the next image).
(c)
The last 320-word block is written from the
secondary output buffer in core onto the disc/
tape file.
(2)
The secondary output destination is set to the file
with LF Type = LFT.
(3) The output card image pointer is set equal to the
serial number in the pointer temporary associated
with LFT, unless the parameter POINTER is present,
in which case, the pointer is set equal to the value
of POINTER.
The physical block containing this
Image is read into the secondary output buffer.
If LFT = 0, then the following steps are performed instead:
(1) The secondary output file which was previously open is
closed, as described above for the case:
I £ LFT s 19;
if none was previously open, a run error - H0T2 will occur.
(2)
If the parameter POINTER is present, then the same pointer
value which has been stored in the internal pointer
temporary for the previously open file will also be
assigned to POINTER.
If HOLLER.OUT is used, the user must declare the Boolean variable
PRINT.OR.NOT in his outermost block.
If PRINT.OR.NOT
true when |11
AL.6g.26
is called by an "E" or "W" In a PRINT statement, a "W" in a READ
statement, or directly in WHAT code, then the print line will be
transmitted to the primary output device as well as to the secondary
output file.
If no secondary output file is open, PRINT.OR.NOT has
no effect. Note that the Boolean value of PRINT.OR.NOT may be set at
any time without calling HOLLER.OUT again. When a secondary output
file is closed by HOLLER.OUT, a Hollerith EOF image is appended to
the file, as described above. The serial number of this EOF image
is the pointer to the "next" image which is saved in the pointer
temporary and perhaps passed to the user via the POINTER parameter.
If the file is subsequently reopened for output with this pointer
restored, the End-of-File image will be written over.
Each time a file is opened by HOLLER.OUT, the disc (or tape) block
containing the card image at which the file is opened is read into
core. However, on succeeding blocks, a read does not precede the
write. Thus, HOLLER.OUT may be used to append images to the end of
a Hollerith file but not to alter images in the middle of an existing
file; the routine HOLLER.OVER should be used for the latter purpose.
WARNING:
If an ALGOL program terminates before the secondary output
file is closed by a call:
HOLLER.OUT(0), as many as the last 16 card
images outputted to that file may be lost
If an attempt is made to "HOLLER.OUT" (or "-.OVER") the last
card image of the entire physical file, an End-of-File image will be
written instead but no error indication will be given; an attempt to
write another image, beyond the physical end of the file, will result in an error "H0T3". There should always be an EOF image as the
last card image of the physical file; however, closing
HOLLER.OUT(0) may write another EOF image earlier.
a file with
AL.6g.27
A page heading or page number which is output to the primary file
under control of the |212 and |213 switches (see Chapter 3d) will not
appear in the secondary output file. Similarly, run error messages
produced by the ALGOL error diagnostic routine as well as output from
DEBUG.PRINT will appear only in the primary output file. Thus,
DEBUG.PRINT statements can be inserted into a program without changing
the number of images sent to the secondary file.
The operation of HOLLER.OVER Is similar to HOLLER.OUT with two
differences:
(i)when it closes a secondary file;
HOLLER.OVER does not output an End-of-File image
(2) HOLLER.OVER reads each block into core before it
is altered and written out. Thus, HOLLER.OVER may
be used to alter images in the middle of an already
existing Hollerith file.
If an error is detected in the HOLLER.OUT or HOLLER.OVER routine,'
the secondary file will be closed if it was open, and no new secondary
file will be opened; however, the last block (up to 16 card images)
may be lost.
Both HOLLER.OUT and HOLLER.OVER produce the following run error
messages:
RUN ERROR
HOTl
LFT < 0 or LFT > 19
RUN ERROR
H0T2
Attempt to close a secondary file when
there was no secondary output file open.
RUN ERROR - HOT3
Attempt to open a LF Type which was not
predefined or defined by AND.FILE or AND.
RUN ERROR - H0T4
Attempt to write outside the bounds of
the physical file.
RUN ERROR - HOTS
Attempt to write on file marked read-only
(i.e., another user's file).
AL.5.ANDFILE.1
^-v
ALGOL Relocatable Library
PROCEDURE SPECIFICATION
procedure
AND.FILE (USER, PROG, LF.TYPE, BUFF.LOC, ERR.EXIT);
value
PROG, LF.TYPE;
string
USER; integer
PROG, LF.TYPE, BUFF.LOC; label ERR.EXIT;
PURPOSE
AND.FILE associates Logical File Type number LF.TYPE with the AND
program ("file") specified by USER and PROG.
Thus an ALGOL user may
define (or redefine) entries in the Monitor Logical File Table during the
ALGOL run as well as during execution of the AND system.
See Chapter 6g
for more information.
PARAMETERS
USER = The AND "User" number for the file, an eight character
alphanumeric string; this string may appear either as an
8-character string constant (e.g. ^33^*01') or as the
name of the first of two successive elements of a logic
array which contain the string as value (see example in
Chapter 6g).
PROG = The AND "Program" number of the file.
LF.TYPE = The Logical File Type to be associated with this AND
file; LF.TYPE must lie in 1 * LF.TYPE 5 19.
BUFF.LOC = An array element which is the first element of a
vector of at least 320 words; this array will be changed
by AND.FILE.
ERR.EXIT
s
A label to which AND.FILE will exit if any of its
parameters are improper or if the designated AND file
does not exist in the AND Directory.
METHOD
The AND file "USER, PROG" is looked up in the AND Directory and
Logical File Type LF.TYPE is associated with it. The 320 locations
AL.5.ANDFILE.2
starting at BUFF.LOC are used as a buffer to read the AND Directory.
After the call of AND,FILE, this space is available for other uses.
See Chapter 6g for an example.
ALARMS
If AND.FILE Is called to look up an AND file under a man number
differing from the man number appearing on the Job Card, then the corresponding Logical File Type will be marked as "read-only".
Any of the following errors will cause AND.FILE to print an appropriate error message and exit to the label ERR.EXIT without assigning
the Logical File Type.
1. Usage number is improperly formed or not in AND Directory.
2.
Program number is out of range or not in AND Directory.
3. Designated file is empty (contains 0 words) and can therefore
be neither read nor written.
4.
Logical File Type is < I or > 19.
5.
Selected AND file is on a tape which is temporarily unavailable.
6.
The AND instruction DONT has not been executed, so the AND
Directory cannot be read by this CP.
7.
An attempt has been made to access another man's file which
has been marked "secret" by the AND instruction SECRET.
(See the AND writeup.)
AL.5-ANDCALL.1
^
PROCEDURE SPECIFICATION
procedure AND.CALL (IMAGES.IN.SCRATCH);
value
IMAGE S.IN.SCRATCH;
integer
IMAGES.IN.SCRATCH;
PURPOSE
AND.CALL may be used to enter the AND system to operate on card images
or binary information written into the AND Scratch Area by an ALGOL program.
METHOD
The AND system is loaded and entered by a special entry, which sets the
AND Scratch pointer, a, to (IMAGES.IN.SCRATCH) + 1 .
If Scratch contains
binary information, IMAGES.IN.SCRATCH should be set to I(Number of words of
binary information + 20)/21.
Once loaded, AND will operate as usual,
reading and executing AND instruction cards from the Hollerith file which
is currently open for input.
Before executing the AND.CALL procedure, the ALGOL program must have
loaded the AND Scratch Area (Logical File Type = 1 or 2) with card images
using HOLLER.OUT or DISC.WRITE, or binary information using DISC.WRITE.
It is not possible to return to the original ALGOL program after the
execution of AND.CALL, since the AND system overlays all of core; however,
ALGOL may be called from AND to perform a new translation.
EXAMPLE:
An ALGOL program has generated 20 card images in AND Scratch, at
which point it executes an AND.CALL (20). The AND system is then loaded
and entered with cr «-21, and AND begins reading cards. If the first card
contains the AND instructions:
AN
FILE, 6/0 ; DUMP; DONE;
then the 20 images generated by the ALGOL program will be dumped as the
20 cards of AND file 6.
AL.5.H0LLERIN.1
PROCEDURE SPECIFICATION
procedure
value
HOLLER.IN (LF.TYPE);
LF.TYPE ; integer LF.TYPE;
or
procedure
value
HOLLER.IN (LF,TYPE, POINTER);
LF.TYPE; integer
LF.TYPE, POINTER;
PURPOSE
HOLLER. IN sets the Monitors card source pointers for Hollerith
card reading to an image in the disc/tape file with Logical File Type =
LF.TYPE.
After a call of HOLLER.IN has selected a file in this way,
executions of "E" or "W" primaries in ALGOL read statements (or an
explicit call for |16 in machine language) will bring in successive
card images from this file. See Chapter 6g for more information.
PARAMETERS
LF.TYPE = The Logical File Type to be selected as Hollerith input
source, replacing the previous source. LF.TYPE in the
range:
1 5 LF.TYPE £? 19 represents one of the pre-
assigned files or an AND file; LF.TYPE = 0 always
represents the "primary" Hollerith card source, the
one in effect when the ALGOL program began execution.
If 1 s LF.TYPE S 19, then:
POINTER = An arithmetic expression whose value is the serial
number of the first image to be read from file LF.TYPE.
If POINTER is omitted, then the first image to be read
will be the one after the last image read during the
last previous selection of this LF.TYPE by HOLLER.IN;
however, if HOLLER.OUT or HOLLER.OVER have also selected
the same LF.TYPE, then the rule is more complicated;
see Chapter 6g.
If file LF.TYPE has not been previously
AL.5.HOLLERIN.2
selected
during
if P O I N T E R
If L F . T Y P E
=
POINTER
0
is
this
run,
POINTER =
1 will
be
assumed
omitted.
then:
= An
arithmetic
serial
number
viously
variable
of
which will
the next
selected
card
be
to be
set
read
equal
to
from
the
the
pre¬
file.
METHOD
See
Chapter
6g
for
complete
discussion.
or
ALARMS
RUN E R R O R
- HINl:
LFT < 0
RUN E R R O R
- HIN2 :
An
attempt
source
RUN E R R O R
- HIN3:
The
- HIN4:
has
Logical
POINTER <
to
1,
19.
been made
(LFT = 0)
assigned
RUN E R R O R
LFT >
File
to
select
is
already
when
it
Type
specified
has
the
primary
selected.
no
file
it.
or b e y o n d
the
physical
End-of-File
AL.5.DISC READ/WRITE.1
ALGOL Relocatable Library
PROCEDURE SPECIFICATION
DISC.READ (NWDS, FIRST.LOC, LF.TYPE, BLK.NO, EOF.EXIT);
DISC.WRITE (NWDS, FIRST.LOC, LF.TYPE, BLK.NO, EOF.EXIT);
value
NWDS, LF.TYPE, BLK.NO;
label
EOF.EXIT; integer
NWDS, LF.TYPE, BLK.NO;
PURPOSE
DISC.READ reads information from disc or tape into an array in
core memory; DISC.WRITE writes the contents of an array in core memory
out onto disc or tape. These routines allow the user to move binary and
Hollerith information in bulk between core memory and disc/tape files.
See Chapter 6g for a complete discussion.
PARAMETERS
NWDS = Number of machine words to read or write.
FIRST.LOC = An array element which is the ALGOL name of the first
word in core memory to read or write.
LF.TYPE = Logical File Type (explained in Chapter 6g).
BLK.NO = Number of the first 320-word block to be read or written
(the first block of the file has block number 0 ) .
EOF.EXIT = Label through which the routine will exit if the
physical End-of-File is reached during the operation.
METHOD
DISC.READ reads into core memory exactly NWDS words, where NWDS Is
not necessarily a multiple of 320. DISC.WRITE will write enough extra
words (generally "garbage") to complete the last 320-word physical
record. These routines initiate direct input/output transmission between
core memory and the tape or disc unit; there is no buffering.
Attempting to read or write beyond the physical End-of-File will
cause the routine to complete the operation up to the End-of-File, and
AL.5.DISC READ/WRITE.2
then exit through the EOF.EXIT label.
ALARMS
DISC.READ AND DISC.WRITE give the same error messages, aa follows:
RUN ERROR - RWRl:
The specified Logical File Type has not been
pre-assigned or assigned by AND or by AND.FILE.
RUN ERROR
RWR2:
A negative number of words has been called for.
RUN ERROR
RWR3:
The FIRST.LOC address lies outside user's
memory.
RUN ERROR
RWR4:
LF.TYPE is out of range:
1 3 LFTYPE * 19.
RUN ERROR
RWR5:
DISC.WRITE has been asked to write on a file
which is marked "read-only".
AL.5.HOLLE ROUT.1
'
PROCEDURE SPECIFICATION
procedure
value
HOLLER.OUT (LF.TYPE);
LF.TYPE ; integer
LF.TYPE;
OR
procedure
value
HOLLER.OUT (LF.TYPE, POINTER) ;
LF.TYPE; integer
LF.TYPE, POINTER;
PURPOSE
HOLLER.OUT sets switches which cause subsequent Hollerith print images
to be appended to the disc/tape file with Logical File Type = LF.TYPE.
The output file selected by HOLLER.OUT is referred to as the "secondary
output" file. When a secondary output file has been selected by HOLLER.OUT,
each execution of an "E" or "W" instruction in an ALGOL print statement
(or a "W" instruction in an ALGOL read statement) copies the first 80
characters of the output line, followed by a four character serial number,
into the secondary output file as the next 84-character image.
A Boolean variable PRINT.OR.NOT, global to HOLLER.OUT, determines
whether or not the print image will be transmitted to the "primary" output
destination(s) (the LP12 printer and/or teletype output file) in addition
to the secondary file.
PARAMETERS
LF.TYPE = The Logical File Type to be selected as the secondary
output file.
If another secondary file is currently
selected, then a Hollerith End-of-File image will automatically be written as the next image in this latter
file, and its image pointer will be saved with the
Logical File Type. Then:
If
IF.TYPE lies in the range 1
LF.TYPE s 19,
the file associated with LF.TYPE will be selected as
the secondary output file.
AL.5.HOLLEROUT.2
If LF.TYPE = 0, no secondary file will be
selected; all subsequent print images will be
directed to the primary output destination,
regardless of the truth value of PRINT.OR.NOT.
If 1 =? LF.TYPE * 19 then:
POINTER = An arithmetic expression whose value is the serial
number of the first image to be appended to the
secondary file.
If POINTER is omitted, then the
first image written will be the next after the
last image written during the most recent selectic
of this LF.TYPE by HOLLER.OUT; however, if HOLLER,
or HOLLER.OVER have also selected the same LF.TYPI
then the rule is more complex (see Chapter 6g).
LF.TYPE has not been previously selected during tl
run, POINTER = 1 will be assumed if POINTER is
omitted.
If LF.TYPE = 0 then:
POINTER = An arithmetic variable which will be set equal to
the serial number of the EOF Image written into
the previously selected file.
PRINT.OR.NOT = A Boolean variable global to HOLLER.OUT. Th
user must declare the variable PRINT.OR.NOT in hi
outer-most block.
Its value can be changed by th
main program to turn primary output printing on
(true) or off (false) without calling HOLLER.OUT
again. PRINT.OR.NOT is Ignored when no secondary
output file is selected.
METHOD
See Chapter 6g for complete discussion.
AL.5.HOLLEROUT.3
r
ALARMS
RUN ERROR
HOT1:
LF.TYPE < 0 or LF.TYPE > 19.
RUN ERROR
HOT2:
LF.TYPE = 0, and there is no secondary file currently
selected.
RUN ERROR
HOT3:
Logical File Type LF.TYPE has no file assigned to it.
RUN ERROR
H0T4:
POINTER < 1, or beyond the physical End-of-File.
RUN ERROR
H0T5:
Attempt to write on file marked read-only
(i.e.,
another user's file).
USE
Before an ALGOL program using HOLLER.OUT terminates execution, it
must call HOLLER.OUT(O) to write out the last physical record of the lastused secondary output file; a Hollerith End-of-Flle image will be written
onto the file at this time.
If the programmer fails to do this, he will
lose up to the last 16 card images.
r
T
AL.5.HOLLEROVER.1
PROCEDURE SPECIFICATION
procedure HOLLER.OVER (LF.TYPE);
value
LF.TYPE;
integer
LF.TYPE;
OR
procedure
HOLLER.OVER (LF.TYPE, POINTER);
value LF.TYPE;
integer
LF.TYPE, POINTER;
PURPOSE
HOLLER.OVER is basically the same as HOLLER.OUT. While HOLLER.OUT
appends Hollerith output images to a file, however, HOLLER.OVER allows
the user to alter ("overwrite") any individual card images in the middle
of an existing AND file (which may have been created originally by AND
or by HOLLER.OUT).
METHOD
HOLLER.OVER differs from HOLLER.OUT in two ways:
(1) HOLLER.OVER does not write a Hollerith End-of-File image onto
the previously selected secondary record. HOLLER.OVER writes
an
End-of-File image only if an attempt is made to write on
the last image of the physical file.
(2)
HOLLER,OVER reads each block of the file as it currently exists
into the output buffer before new images are entered.
PARAMETERS
See AL,5.HOLLER.OUT.
ALARMS
See AL.5.HOLLER.OUT.
r
ERRATA
Two minor features of the HOLLER.OUT and HOLLER.OVER routines do
not yet function as described in Chapter 6g. These features are as
follows.
(1) HOLLER.OUT
(and —
.OVER) do not yet use the complete AND
serial numbering system for serial numbers > 9999; instead,
these routines now supply purely numeric 4-digit serial
4
numbers, modulo 10 . See Section I of Chapter 6g.
(2) Page headings, run error messages, and DEBUG.PRINT output
will appear in an open secondary output file as well as in
the primary output file.
Both
tliGSG
See Section V B of Chapter 6g.
f G s t u i r c s wi.11 soon. be coir ITGC ted to corxcspond to Chftptsr 6g •
CHAPTER 6h
r
Storage Allocation
Algol programs go through 3 phases:
compilation of the program,
loading and relocation of all relocatable subroutines, and running of
the program.
The same area of memory may be used for different pur-
poses at the three different times.
It is necessary to have some
understanding of this storage allocation to understand how much space
is available for program and for data, and to understand how this
space can be expanded.
On page AL.6h.2 is a memory map showing storage
allocation at the three times. A vertical arrow (t or I) indicates an
area of storage which may expand to the next horizontal line. Opposing
vertical arrows (!) indicates areas of storage which may expand until
they meet. A vertical arrow terminated by a horizontal line indicates
that the exact upper (or lower) bound of the area is different for each
program.
At the end of each Algol program the "words
printed is the total
number of words which would be dumped if the program were dumped as a
segment - the space from A to B on the memory map. Call this number NWRDS,
Since the total space available for this information and for data is
C - A = /56720 = 24016, locations
o
the total space available for data (scalars, arrays, own scalars, own
arrays) is 24016,„ - NWRDS. Let the space required for WHAT labels be
NWHAT. Then the space originally available for a program and for WHAT
labels is
E - D = /27630 = 12384„ locations
The total space permitted the program is thus 12384 - NWHAT. Doing
10
"Release WHAT" and "Release Symbolic library" increases the program space
to
F - D = /32030 = 13336 locations.
10
Changing the number of abcons and adcons changes the location of D
and so changes the amount of space available for the program. The system
statement "n ABCONS", which is described in detail in Chapter 4, causes
D to be set to G + 2n. Since n is initially 200 , D is G + 400 .
10
lo
At.6h.2
COMPILE
RUN
RELOCATE
77777
M O N I T O R
73000
SUBROUTINE
TEMPS
RELOCATOR
FIXED
SUBROUTINES
OWN SCALARS
RELOCATOR
65000
72634
©> 7000
OWN ARRAYS
TRANSLATOR
43200
(7)
SYMBOLIC LIBRARY
DIRECTORY
t
RELOCATABLE
I
SUBROUTINES
42400
41000
ARRAYS
©
Altered by
SY Abcon_
<I1150)(D)
A B C O N S
10330
0
10060
(A)
S Y S T E M
AND
A D d O N S
C O N S T A N T S
M O N I T O R
(All addreuea are octal)
SCALARS AND
STATEMENT
TEMPS
PROGRAM
AND
RELOCATABLE
SUBROUTINES
©
©
©
©
A L . 7 a . l
Revised Report on the Algorithmic Language
A L G O L 60
PETER
NAUR
(Editor)
J. W - B A C K U S
C. K A T Z
H. R U T I S H A U S E R
J. H .
F. L. B A U E R
J. M C C A R T H Y
K. S A M E L S O N
A.
J. G R E E N
A . J. P E R L I S
B. V A U Q U O I S
M.
Dedicated
to
the
Memory
of
WILLIAM
TU
RAN
SKI
CONTENTS
T h e report gives a complete d e n n i n g description o f the
a language
language A L G O L
60. T h i s
is
suitable for expressing a large class o f nu¬
merical processes in a form sufficiently concise for direct
INTRODUCTION
1.
STRUCTURE
1.1.
2.
T h e introduction contains an account o f the preparatory
w a s defined. I n a d d i t i o n , the n o t i o n s , reference language,
hardware
representations
are
explained.
I n the first chapter, a survey o f the basic
and
features o f the language
constituents
is g i v e n , and the
3.
3.1.
3.2.
3.3.
3.4.
3.5.
notation, by w h i c h the syntactic structure is d e n n e d , is
explained.
T h e second chapter lists all the basic s y m b o l s , and the
are
defined. F u r t h e r ,
some
important
notions
such
4.
Three
Boolean
(logical) and designational.
T h e fourth chapter describes the operational units
of
5.
are:
assignment
ecution
of
statements
(evaluation
of a
dummy
statements,
formula),
and
pro¬
cedure statements (call for execution o f a closed process,
defined by a procedure
declaration).
The
formation
of
STRINGS.
LETTERS
DIGITS. LOGICAL VALUES.
DELIMITERS
IDENTIFIERS
NUMBERS
STRINGS
QUANTITIES, KINDS AND SCOPES
VALUES AND TYPES
VARIABLES
FUNCTION DESIGNATORS
ARITHMETIC EXPRESSIONS
BOOLEAN EXPRESSIONS
DESIGNATIONAL EXPRESSIONS
5 . 1 . * T Y P E DECLARATION*
5 . 2 . ARRAY DECLARATIONS
5 . 3 . SWITCH DECLARATIONS
5 . 4 . PROCEDURE DECLARATIONS
(explicit break o f the sequence o f ex¬
statements),
AND
DECLARATIONS
the language, k n o w n as statements. T h e basic statements
go to statements
NUMBERS,
4 . 1 . C O M P O U N D STATEMENTS AND BLOCKS
4 . 2 . A S S I G N M E N T STATEMENTS
4 . 3 . G O TO STATEMENTS
4 . 4 . D U M M Y STATEMENTS
4 . 5 . CONDITIONAL STATEMENTS
4 . 6 . F O R STATEMENTS
4 . 7 . PROCEDURE STATEMENTS
as
T h e third chapter explains the rules for forming ex¬
different types o f expressions exist: arithmetic,
IDENTIFIERS,
STATEMENTS
quantity and value are defined.
pressions and the m e a n i n g o f these expressions.
LANGUAGE
EXPRESSIONS
formal
syntactic units k n o w n as identifiers, n u m b e r s and strings
SYMBOLS,
2.1.
2.2.
2.3.
2.4.
2.5.
2.6.
2.7.
2.8.
w o r k leading up to the final conference, where the language
and
THE
BASIC CONCEPTS.
automatic computers.
language
OP
F O R M A L I S M FOR SYNTACTIC DESCRIPTION
BASIC
automatic translation into the language o f p r o g r a m m e d
publication
WIJNGAARDEN
WOODGER
SUMMARY
international algorithmic
WEGSTEIN
VAN
EXAMPLES
OF
ALPHABETIC
PROCEDURE
INDEX
SYNTACTIC
OF
DECLARATIONS
DEFINITIONS OF
CONCEPTS
AND
UNITS
more complex structures, h a v i n g statement character, is
explained.
These
include:
statements, c o m p o u n d
conditional
statements, and
statements,
for
blocks.
T h i s
I n the fifth chapter, the units k n o w n as declarations,
serving
entering
for defining
permanent
into a process
properties
described
o f the
in the language,
units
are
defined.
T h e report ends w i t h two detailed examples o f the use
o f the language and an alphabetic index o f definitions.
report
t a n e o u s l y
of
the
the
w a s
in
ACM,
6,
N u m e r i s c h e
C o m p u t e r
p u b l i s h e d
the
No.
1
(1963),
M a t h e m a t i k ,
J o u r n a l .
s i m u l -
C o m m u n i c a t i o n s
1-17 ,
and
the
REVISED ALGOL 60
a
nT
dION
the c
oh
nf
erenc
e
ae
dn
oc
pe
tedtht
h
ispr
no
ec
w
formtoasw
I
N
T
I
t
O
n
i
J
C
i
t
s
report,
T
e
C
o
n
f
e
r
e
n
e
e
d
e
d
Bl
ag
c
k
g
rh
o
u
nd
A
f
ti
et
(helangu
pa
ub
l
icatA
io
ngol,
of
a pp
r
e
l
i
m
i
naryatareport,
.
.r
i
th
e
g
r
e
e
m
e
n
t
,
o
n
en
ai
co
hnio
tf
emto
f
th
e
re
ee
p'
os
rt.con
Tc
hee
a
o
r
m
i
c
g
e
l
'
l
i
s
r
e
p
a
n
d
1
1
c
o
n
f
e
r
e
c
ela
r
e
p
r
e
s
e
n
t
s
t
h
e
u
h
e
C
o
m
m
i
t
t
pts
i
n
Z
i
i
r
i
c
h
i
n
H
I
.
W
,
m
u
c
h
i
n
t
e
r
e
s
t
,
i
n
t
h
A
l
g
o
l
g
u
a
g
e
i
n
t
e
r
s
e
c
t
i
o
n
o
f
i
t
*
a
g
r
e
e
m
e
n
t
s
.
dcv
e
lo|>
cd.result of mi informal meeting held at, Mains! in
A
s
ft
Ne
o
v
c
ml
lxrEurl
!
>
5
8
, ca
b
ot
ur
t
for
t
y
ia
nt
erestA
ed
A
pp
eri
s
l
o
n
*
]e%
f
2
r
o
mConference [Edited by M. W<Hidger
s
v
e
r
a
o
p
e
a
n
o
u
n
i
e
s
h
e
l
d
n
l
g
o
l
i
m
p
l
c
m
n
t
a
AA
m
e
e
t
i
n
g2o
f-,.i s
o
m
e
o
f
tH
he
autho
r
s
ofth
A
l
g
oh
t
i
o
n
c
o
n
f
e
r
e
n
c
e
i
n
C
o
p
e
n
h
a
g
e
n
i
n
F
e
b
r
u
a
r
y
I
!
I
5
<
)
.
A
o
n
p
r
i
l
1
H
0
2
i
n
o
m
e
,
I
t
a
l
y
,
r
o
u
g
"i
h
a
r
dwarf
elowngrout
po
"w
ae
sf
ov
re
m
edof
forth
we
orkin
g
coope
r
a
t
i
v
e
l
y
a
n
d
c
o
u
r
t
e
s
y
o
f
t
he
Is
ne
te
r
n
ational Computation
r
g
h
t
t
h
l
e
l
p
a
p
e
r
t
a
p
e
e
o
i
l
e
.
T
i
s
T
h
e
f
o
l
l
o
w
i
n
g
w
e
r
e
p
r
e
n
t
:
<
f
eg
re
n
c
ea
l
soal
ed AU10L
to Hie publice
ad
ti
it
oe
nd hy
ItP
eg
n
e
c
cntralcn,
C
o
p
e
n
h
a
e
n
,
o
f
n
b
y
e
t
e
r
J
t
i
n
n
N
a
u
r
,
w
h
i
c
h
s
e
r
v
e
d
a
s
a
f
o
r
u
m
,
f
o
r
f
u
r
t
h
e
r
d
i
s
c
u
s
s
i
o
n
.
D
u
r
i
n
gng,thebot,
bmeform
W
>\) a
1n
0d11'inf
Co
o
n
f
e
renceoneJ
i
n
P
a
r
i
slieh
s
e
ve
r
alII.M.
I
'
'
.Cr
L
.r
n
o
r
P
m
i
l
Wa.
L,, I
vK
an
m
e
e
t
i
h
a
l
r
m
a
l
s
,
w
e
e
e
l
d
.
.
c
o
i
i
K
n
i
n
c
i
d
H
i
(
C
h
i
r
m
a
n
C
.
K
i
ll
ly
s
I'. '/,. Inter
n
u
mup TA(L;GOL2
.
1
T
hesethemee
tt
ie
nn
g
s ofrevea
l
e
d gr
so
o
m
ewhm
i
s
undew
rs
t
an
d
i
nr
g
s
a
sresponsible
.
1
1
.
K
o
g
o
n
G
r
o
)
t
o
i
n
t
t
h
e
u
p
i
c
h
a
s
p
i
m
a
r
i
(i
ru
ep
r
e
s
e
n
th
in
g.).sam
We.time
f
o
r
t
h
e
f
o
r
m
u
l
a
t
i
o
n
o
f
t
h
e
l
a
n
g
u
a
g
e
,
h
u
t
a
t
e
M
k
i
i
H
)
mf
a
dr
e
i
tnvolc
l
e
a.
rt
h
atather
e
exist
s
a
wid
e
a
p
p
r
e
c
i
as
t
i
o
n woa
fs(i
t.
he
1
'
.
N
m
i
r
e
f
o
t
i
v
e
d
A
s
r
e
s
u
l
t
o
f
t
h
e
d
i
s
c
u
s
s
i
o
n
s
i
t
d
e
K
.
i
i
n
m
c
l
o
n
Seegm
ii
lierUtmtin
J
.
H
.
W
e
g
s
t
e
i
n
I
t
.
K
.
c
i
d
e
d
t
o
h
o
l
d
a
n
i
n
t
e
r
n
a
t
i
o
n
a
l
m
e
e
t
i
n
g
i
n
J
a
n
u
a
r
y
!
<
)
(
»
)
A
.
v
a
n
Wi
j
nga
ari
dn
cn1'. Lnndln
f
o
r
improA
vt
ingatheEuro
Ap
le
g
o
lA
ll
an
g
u
ageCoa
n
drencp
re
par
i
n
g
a
final
M
.
W
o
o
d
g
e
r
r
e
p
o
r
t
.
a
n
g
o
l
n
f
e
e
i
n
P
a
i
s
To
h
e
pn
u,
r
p
o
s
e
op
ft t
h
e el
mi
em
ei
tn
i
n
g
w
ap
s
toamc
o
r
r
N
o
v
e
m
b
e
r
1
!
>
!
.
>
w
h
i
c
h
w
a
s
a
t
t
e
n
d
e
d
b
y
a
b
o
u
t
fifty
p
e
o
p
l
,
e
r
r
r
s
i
a
t
t
e
m
t
o
a
t
e
a
p
a
r
e
n
t
b
i
g
u
s
e
v
en.Ja
En
uu
r
o
p
eanHMr
e
presen
t
a
t
i
vr
ee
snce,wereandselec
t
e
d
tr
oepr
a
t
t
e
n
d
a
n
d
o
t
h
e
r
w
i
s
e
c
l
a
r
i
f
y
t
h
e
A
l
g
o
l
G
O
l
t
c
p
o
r
t
.
t
h
e
a
r
y
M
)
C
o
n
f
e
t
h
e
y
e
s
n
t
t
h
e
t
oe
t
h
e
ip
ao
ns
ga
u
a
gefow
erecorr
n
o
t
cons
i
d
eredclari
af
t
t
h
f
oi
lt
li
os
wh
ingCo
om
rp
ga
n
i
zr
ation
s
:cietA
s
socia
t
i
o
n
F
rt
anchis
e
d
C
a
l
c
u
l
,
V
a
r
i
o
u
s
p
r
o
l
s
r
e
c
t
i
o
n
a
n
d
i
c
a
t
i
o
n
B
r
u
t
e
S
o
y
,
G
e
s
e
l
l
s
c
h
a
f
f
i
i
r
A
n
g
e
w
a
n
d
t
e
wu
ee
rs
e
s
u
b
m
itted
by interestedNop.
arties
in
respu
os
ne
s
e
M
a
t
h
e
m
a
t
i
k
u
n
d
M
c
c
h
a
n
i
k
,
a
n
d
N
e
d
e
r
l
a
n
d
s
U
e
k
e
n
Q
t
i
o
n
n
a
i
r
e
i
n
1
4
w
e
r
e
d
m
arhinc Gcnoofcschp
ar
p
.
T
em
se
ee
v
e
n
p
resen
ta
at
vu
es
heldDeca
g
i
d
e
.
final
e
parat
oh
ry
t
i
ngre
a
t
M
ii
n
z
i
n
e*
mberconstitutes a supplement to the
T
h
i
s
r
e
p
o
r
t
Mg
ee
a
n
whil
ea
,nges
inor
thecor
U
n
i
t
e
d
Sta
t
es,Alg
ao
nl
yoneR
wr
h
orequw
i
s
h
e
t
oould resolve a number of
e
p
o
t
h
i
c
hdt
s
h
s
u
g
s
t
c
h
r
e
c
t
i
o
n
s
t
o
w
a
s
e
s
t
e
d
o
t
h
e
r
e
i
n
.
N
o
t
a
l
l
ofbethr
eesolv
qu
e
s
tionB
sather
aised
con
s
e
n
d
h
i
s
c
o
m
m
e
n
t
s
t
o
t
h
e
o
r
i
g
i
n
a
l
r
e
p
o
r
t
c
o
u
l
d
e
d
.
r
t
h
a
n
w
h
erebas
ti
hs
eyof
werecons
p
u
b
l
it
si
ho
en
d.fo
Tr
hesechan
c
o
m
ment
s
e
ncoA
b
e
co
a
m
d
r
ah
wt
nh
na
c
l
u
s
i
oe
n
sew
o
nambig
auitin
u,
mbertheofcom
s
ui
bt
tt
le
pd
oe
i
t
h
e
i
d
e
r
a
g
e
s
i
n
t
h
e
l
g
l
l
a
n
m
i
g
c
r
e
t
e
n
e
s
m
e
e
g
us
a
g
e.Al
Bo
t
h
t
h
e
Shakg
kroupa
n
da
U
S
Ebo
ot
rg
an
i
z
a
t
i
o
n
s
e
s
t
ab-those points which they unanimous
r
e
p
o
r
t
o
n
l
y
l
i
h
e
d
g
o
l
w
o
r
k
i
n
g
s
,
n
d
h
o
r
g
a
n
i
z
a
t
i
o
n
s
cou
l
d
br
e
ta
t
e
d
inwi
cl
e
arth
ae
ndfo
ul
n
a
m
bn
i
guoua
sreasfash
w
e
r
e
r
e
p
r
e
s
e
n
t
e
d
o
n
t
h
e
A
C
M
C
o
m
m
i
t
t
e
e
o
n
P
o
g
r
a
m
Q
u
e
s
t
i
o
n
s
c
o
n
c
e
r
n
e
d
t
h
l
o
w
i
g
m
in
ngin
Langu
a
gv
ee
*m
.lwrThe195!
A)CMand
Commi
t
ts
e
e
metf
int
W
a
s
h
i
n
g
o
r
f
u
r
t
h
e
r
ci
oo
nn
s
in
dera
t
i
o
nc
bu
y
Worki
n
g
Gr
o
upad
2
.
1
i
n
h
c
j
>
x
p
c
e
t
a
t
t
h
a
t
r
r
e
n
t
w
o
r
k
o
n
v
a
nce
t
o
N
o
c
o
n
i
d
e
r
e
d
a
l
l
c
o
m
m
e
n
s
o
*
I
K
b
i
t
o
b
'
r
N
o
t
b
.
T
h
e
p
r
e
s
e
n
t
,
e
d
i
t
i
o
n
f
o
l
l
o
w
s
A
l
g
o
l
(
.
h
a
t
h
a
d
b
e
e
n
s
e
n
t
t
o
t
h
e
A
C
M
w
h
sa
p
pe
r
o
ve
d
l
>
vtt
.
iopr
C
o
u
n
c
i
lv
o
f
1i
Fs
lU
Ir
'n
.o
Ar
l
t
h
A
l
s
o
,
s
e
v
e
n
r
e
p
r
e
s
e
n
t
a
t
i
v
e
s
w
e
r
e
s
e
l
e
c
t
e
d
t
o
t
t
n
d
t
h
e
h
e
I
n
r
o
u
c
t
i
o
n
,
h
e
e
s
e
n
t
,
e
r
s
i
o
n
i
g
i
J
a
n
u
a
r
y
I
9
6
0
i
n
t
e
r
n
a
t
i
o
n
a
l
c
o
n
f
e
r
e
n
c
e
.
T
h
e
s
e
s
e
v
e
n
J
a
n
u
a
r
y
V
m
c
o
h
e
r
e
n
c
e
m
o
d
i
f
i
e
d
a
c
c
o
r
d
i
n
g
t
o
t
h
e
r
t
a
t
il
v>
ec
srhe
l
d
n
Bi
on
s
to
nthe
r
eg
an
ce
h
edinhe
dr
ue
r
g
A
p
ra
it
ledI
S
K
f
iDc
o
nfere
ne
cs
ee
.ntTlv
ie
ur
xsiont
t
i
o
d
i
n
i
n
c
o
r
p
o
r
i
n
i
e
p
r
.e
ie
nprese
Dn
e
c
e
m
1
9
.VJ.a final preparatory meeti
t
i
o
n
s
L
o
w
e
l
l
H
i
e
o
r
i
g
i
n
a
l
r
e
p
o
r
t
i
n
M
m
f
o
l
l
o
w
i
n
g
s
o
f
text:
1
w
i
t
h
foo
t
n
o
t
e
;'
2
.1
footno
t7
e
;
2
.;
3;42
January 1960 Conference
4
.
2
.
3
;
1
,
2
.
4
;
4
.
3
,
4
;
4
.
7
.
3
;
4
.
7
.
3
.
1
;
4
.
.
3
3
.
5
;
5
.
3
.
3
;
5
.
3
.
5
;
5
.
4
.
3
;
5
.
4
.
4
;
5
.
4
.
5
.
C
h
a
n
g
e
s
o
f
T
h
e
thiG
rt
e
en
r
epres
e
n
tl
aa
tn
iv
e
s,S
fw
ri
ot
mzerlD
e
n,
mark
,
E
n
g
l
a
n
d
,
4d
,2
.1
;
4
.
5
,
1
.
1
F
r
a
n
c
e
,
e
r
m
a
n
y
,
H
o
l
d
,
a
n
d
a
n
t
h
e
U
n
ii
t,
e,Id12
'
P
r
e
l
i
m
i
n
a
r
y
re
p
o
r
t
—
I
n
ti
e
r
natio
n
al Algebraic Languag
C
o
m
m
.
A
C
M
(
l
!
)
5
<
)
,
8
.
Sta
t
e
s
,
c
o
n
f
e
r
r
e
d
i
n
P
a
r
i
s
f
r
o
m
J
a
n
u
a
r
y
I
I
t
o
H
t
!
H
i
O
.
'
R
ee
pe
or
ton
o
n
tr
he
A
lgoriL
ta
hn
mi
c
Langu
a
g
etA
LGOL
h
P
r
i
o
ro
tu
otth
i
s
met
eh
te
ingpra
c
o
m
p
letel
y
newC
d
r
a
f
t
report
w
a
s
o
m
m
i
t
t
e
P
r
o
g
a
m
m
i
n
g
g
u
a
g
e
s
a
n
d
h
e
G
A
M
w
o
r
k
e
d
f
r
o
m
e
l
i
m
i
n
a
r
y
r
e
p
o
r
t
a
n
d
t
h
r
e
c
o
m
mittee
on(10
P
r
o
gram
m
i
n
g
,
edited hy A. J. Perlis
mendations of the preparatory meetings by
P
e
t
e
r
N
a
u
r
5
!
)
)
,
4
1
0
0
.
•omobW
liamjiistTurap
nr
si
k
i
th
he
eJ
A
m
e
r
i
c
g
r
oupConw
se
aut
ii
ll
e
o
ro
tf
ot
a
n
u
a
r
yanI
'
H
i
l
l
fa
er
5
tiullrtin,
Anlkars
A
Olismtr
r
A W O L
Ctmmimiatiitma
of
the
A C M ,
Communications.
1
Num.
Mittk.
1
Bulletin
7
.on:uT
heth
me
ainrefe
pr
ue
bn
lc
ie
catior
ne
sprese
on
ftatit
h.
e ALGOL langua
gr1
am
ming
lang
u
a
g
et
s
w
if
llfu
ln
ec
at
dionstotetterreso
l
u
t
i
w
i
l
l
s
e
o
n
.
S
i
d
e
e
f
f
e
c
s
o
2
.
T
h
en:callstati
bc
yo
nr
amedync
o
n
c
ept
3
.
o
w
a
m
i
c
PUBLICATION LANGUAGE
4
.
F
o
r
s
t
a
t
e
m
e
n
t
:
s
t
a
t
i
c
o
r
d
y
n
a
m
i
c
1
.
Thelan
pa
ub
l
i
ce
ata
ic
oc
nordin
l
angut
ao
geusa
d
m
itsofva
r
i
a
t
i
o
n
s
5
.eCo
n
f
lh
io
cr
tsbe
t
weenthespeci
fication0and
d
e
cla
r
a
t
i
o
n
r
e
f
e
r
e
n
c
e
g
u
g
e
g
a
g
e
p
r
i
n
t
i
n
g
T
h
a
u
t
o
f
ALGOL 0
R
e
p
o
r
t
p
s
e
n
t
t
t
h
r
i
t
im
na
gt
(e.gi
.o
,f
ss
u
bd
scripf
to
*
,s
st
pa
a
c
e
s,ae
x
pone
n
t
s
,
G
r
e
e
k
R
or
m
e
Con
f
e
r
e
nce,onbei
ng awy
areIFI
of
ta
hc
ecepw
f
o
r
i
o
n
a
2
.
I
t
s
u
e
r
t
i
n
g
n
d
c
o
m
m
u
n
i
c
a
t
i
n
g
W
o
k
i
n
g
G
r
o
u
p
ALGOL b
P
,
t
e
d
t
h
a
t
a
n
y
3
.
Ti
h
e
c
h
a
r
a
c
tersbuttouni
bv
e
usedcorrem
ao
yndencb
e
c
o
l
l
e
c
t
ivetoresp
o
ne
sibili
t
yvelow
h
i
c
h
t
h
e
y
mi
i
g
hta
h
a
v
en
w
i
t
h
d
i
f
f
e
r
e
t
c
o
u
n
t
r
i
e
s
,
o
c
a
l
s
p
e
r
e
s
p
e
c
t
t
h
d
e
p
m
e
n
t
,
s
p
e
c
i
f
i
c
a
t
o
n
n
d
r
e
f
n
e
m
e
n
t
rencetrans
rf
ee
pres
entation must be secured.
o
fatthe
ALGOL l
anguage will from now onrefe
b
d
th
b
o
d
y
.
T
h
i
s
repL
oa
rt
he
as
si
bn
eenAug
re
v
i
ewed11*5
b
y aI
F
IPhaT
Cb2
onap-Pro
HAHDWAHB
HEI'HESENTATIONS
g
r
a
m
m
i
n
g
n
g
u
a
g
u
s
t
2
n
d
s
e
e
n
1
.uageF
Ee
a
h
o
n
ebo
f tt
h
eselimi
s
anum
cb
on
d
ensao
tf
ioncha
or
f
po
rr
ovedInfo
br
y
t
hePrC
o
u
n
c
i
l
of the Internati
oa
nn
ag
l
dc
e
r
a
t
i
o
n
l
e
n
f
o
r
c
e
d
y
h
e
i
t
e
d
e
r
f
m
a
t
i
o
n
o
c
e
s
s
i
n
g
.
s
t
a
n
d
ardE
i
n
pn
uo
tneeq
u
ipme
n
ts
.e uses the character se
A
s
w
i
t
h
t
h
e
p
r
e
l
i
m
i
n
a
r
y
ALGOL r
e
p
o
r
t
,
t
h
r
e
e
d
i
f
f
e
r
e
2
.
a
c
h
o
f
t
h
e
l
e
v
eg
ls
ofalanP
gu
ub
al
g
e
a
reLan
re
c
o
g
n
izeda
,ndna
m
e
lr
yar
ac
R
e
f
e
r
encand is the language accepted by
l
o
m
p
u
t
e
L
a
n
u
a
g
e
,
i
c
a
t
i
o
n
g
u
a
g
e
s
e
v
e
l
H
a
r
d
w
a
r
e
for
thE
aa
tchcoo
mn
pe
utero
.f these must be accompanied
Representations.
3
.
s
e
t
.
o
fangur
u
le
e.
s for transliterating from Publication
REFERENCE LANGUAGE
e
n
c
e
l
a
g
t
a
n
sl
t.
er
a
t
i
o
n
bet
w
e
enput
h
e
r
e
f
e
renceamon
lg
anguao
gt
eh
1.
.I
It
ti
st
h
e
wd
o
r
k
i
nn
ggla
n
g
u
a
g
e
of ta
heFor
c
o
mu
mr
i
t
t
ei
e
l
a
n
g
a
g
e
s
u
i
t
a
b
l
e
f
o
r
b
l
i
c
a
t
i
o
n
s
,
2
i
s
t
h
e
e
f
i
n
i
l
a
n
g
u
a
g
e
.
ob
l
l
o
wi
i
n
gao
r
u
l
eu
st
rg
ecomo
mf
ended
.e line between
3e
.
T
h
eg ch
a
r
acters
arebydet
e
r
minedcompb
yerf
as
s
e
f
m
tuala
Le
ob
wr
ea
rc
ik
n
t
h
Se
u
c
r
p
t
b
r
a,
c
k
e
1r
|
u
n
d
r
s
t
a
n
d
i
n
a
n
d
n
o
t
a
n
y
u
t
l
i
m
i
t
i
o
n
s
et
ts
s and removal of th
cod
e
r
s
n
o
t
a
t
i
o
n
,
o
r
p
u
r
e
m
a
t
h
e
m
a
t
i
c
a
l
n
o
t
a
t
i
o
n
.
b
r
a
c
k
e
4l.
It is the basic reference and E
gp
u
i
d
e
f
ompil
e
r
R
a
i
singforo
fo
t
hepa
er
xe
pn
ot
nh
ee
ns
tes, bracket
x
o
n
e
n
t
i
a
t
i
onr(1c)
A
n
y
m
f
P
a
r
e
n
t
h
e
s
e
s
bui
d
e
r
s
.
b
r
a
c
esof the ten and of the
5
.
I
t
ii
ssth
e
gu
i
d
e
fof
rorall
h
at
r
d
wt
a
r
e
r
e
p
r
e
s
e
n
t
a
t
i
o
n
s
.
R
a
i
s
i
n
g
6
.
I
t
t
h
e
g
u
i
d
e
t
r
a
n
s
l
i
e
r
a
i
n
g
f
r
o
m
p
u
b
l
i
c
a
t
i
o
n
B
asisrepro
f
ten i
n
g
in
nt
te
en
gd
ra
l
n
u
mi
b
e
r
,
inses
ri
ti
n
g
l
a
n
g
u
a
g
e
t
o
a
n
y
l
o
c
a
l
l
y
a
p
p
r
o
p
r
i
a
t
e
h
a
r
d
w
a
r
e
e
s
e
n
t
a
t
h
e
i
e
d
m
u
l
t
p
l
i
c
a
t
i
o
n
g
n
tions.
DESCRIPTION OF THE REFERENCE LANGUAGE
s
f
ce
on
taine
dssign
um
ne
in
tt
ss
ot
fateme
tn
ht
es.language—explicit formu
1. Structure of the Language
-e
cl
a
l
l
d
a
T
o
se
h
o
w
tg
ht
eateflow
ofanc
omputs
at
ta
it
oe
nm
ae
lntproc
cl
ea
s
s
e
s
,
A
s
s
t
a
t
e
d
i
n
t
h
e
i
n
t
r
o
d
u
c
t
i
o
n
,
t
h
e
a
l
g
o
r
i
t
h
m
i
c
l
a
n
g
u
a
n
o
n
a
r
i
t
h
m
t
i
e
s
m
e
n
t
s
d
u
s
e
s
h
ar
sdwart
h,
reeand
iffere
n
t
k
i
n
d
s
ofthe
repres
e
n
t
a
to
ip
om
ne
s
—
eferw
n
c
,
a
d
d
e
d
h
i
c
h
mc
ao
ymputd
e
s
cribs
et
,atem
ee
.n
gt
.s
,.aS
li
tn
ec
rn
ativi
et
s,is
or
h
a
e
d
p
u
b
l
i
c
a
t
i
o
n
—
a
n
d
d
e
v
e
l
n
t
d
e
r
e
p
e
t
i
t
i
o
n
s
o
f
i
n
g
e
sc
r
i
b
e
d
inTht
h
ems
e
q
us
elth
ia
st i
n
terms
o
f
to
h
r
e
fe
r
e
n
c
enctio
r
eh
pe
re-of these statements that one
f
r
t
h
e
f
u
n
s
e
n
t
a
t
i
o
n
.
i
s
e
a
n
a
l
l
o
b
j
e
c
t
s
d
e
f
i
n
e
d
w
i
t
h
i
t
r
ef
e
rseqs
ty
on
as
n—
oo
t
h
e
r,stat
se
tm
ae
tn
et
ms
entsmay
maybebeenc
p
r
o
v
i
dedbet
w
l
a
n
g
u
a
g
e
a
r
e
r
e
p
r
e
s
e
n
t
e
d
b
y
a
g
i
v
e
n
s
e
t
o
f
m
b
o
l
a
n
d
A
u
e
c
e
f
l
o
s
e
d
i
t
in
statio
on
n
lyma
in
t
hf
efer.choi
c
e
or
f
sa
yn
m
bolss
t
h
a
t
t
h
et
os
therbegt
woand end to form a
t
a
t
e
m
e
n
t
b
r
a
c
k
e
t
i
n
r
e
p
r
e
s
e
s
y
d
i
S
t
r
u
c
t
u
e
d
c
o
n
n
t
m
u
s
stS
at
ta
et
me
em
ne
tn
.ts are supported by declarations which a
beThethepurs
as
me
eo
ff
orta
l
la
r
e
p
r
e
s
e
n
t
a
tions
.
p
o
h
e
l
g
o
r
i
t
h
m
i
c
l
a
n
g
u
a
g
e
i
s
t
o
do
es
c
r
i
b
eng instructions but inform the
t
h
e
m
s
e
l
v
e
s
c
m
p
u
t
i
c
o
m
p
u
t
a
t
i
o
n
a
l
p
r
o
c
e
s
s
e
s
.
T
h
e
b
a
s
i
c
c
o
n
c
e
p
t
u
s
e
d
f
o
r
t
h
e
l
a
t
o
r
o
t
h
e
x
im
se
te
n
c
e
a
n
d
ce
rs
taintheprope
r
t
i
e
s
d
e
s
c
r
iptio
n
o
f
cac
lo
cn
ut
la
t
i
n
g
ra
ul
escon
i
s
t
h
e
w
e
l
l
k
n
o
w
nfva
a
r
i
t
h-stae
a
p
p
e
a
r
i
n
g
i
n
t
e
n
t
s
,
s
u
c
h
a
c
l
a
s
s
m
e
t
i
c
e
x
p
r
e
s
s
i
o
n
a
i
n
i
n
g
s
s
t
i
t
u
e
n
t
s
n
u
m
b
e
s
,
r
i
t
a
k
e
n
o
n
a
s
v
a
l
u
e
s
b
y
a
v
a
r
i
a
b
l
e
,
t
h
e
d
i
m
a
b
l
e
s
,
a
n
d
f
u
n
c
t
i
o
n
s
.
F
r
o
m
s
u
c
h
e
x
p
r
e
s
s
i
o
n
s
a
r
e
c
o
m
pounded, by applying rules of arithmetic composition,
REVISED ALOOl 40
Reference
Publication
Language
W u
rich
itch
M m lacen; u n d wovon n u n nieht
redan
u b a r h a u p t a a r r a lfaat,
kann,
riarQber
halt
inula m a n aBhwaiaan.
LOOWld
WllTOKIWTETII.
Language
REVISED ALCOl 60
ARRAY OF NUMBERS, OR EVEN THE SET OF RULES DEFINING A FUNCTION. A SEQUENCE OF DECLARATIONS FOLLOWED BY A SEQUENCE OF
STATEMENTS AND ENCLOSED BETWEEN BEGIN AND END CONSTITUTES A BLOCK. EVERY DECLARATION APPEARS IN A BLOCK IN
THIS WAY AND IS VALID ONLY FOR THAT BLOCK.
A PROGRAM IS A BLOCK OR COMPOUND STATEMENT WHICH IS
NOT CONTAINED WITHIN ANOTHER STATEMENT AND WHICH MAKES
NO USE OF OTHER STATEMENTS NOT CONTAINED WITHIN IT.
IN THE SEQUEL THE SYNTAX AND SEMANTICS OF THE LANGUAGE
WILL BE GIVEN.*
2. BASIC SYMBOLS, IDENTIFIERS,
STRINGS. BASIC CONCEPTS.
1.1. FORMALISM FOR SYNTACTIC DESCRIPTION
THE SYNTAX WILL BE DESCRIBED WITH THE AID OF METALINGUISTIC FORMULAE. THEIR INTERPRETATION IS BEST EXPLAINED
BY AN EXAMPLE
THIS ALPHABET MAY ARBITRARILY BE RESTRICTED, OR EXTENDED
WITH ANY OTHER DISTINCTIVE CHARACTER (I.E. CHARACTER NOT
COINCIDING WITH ANY DIGIT, LOGICAL VALUE OR DELIMITER).
LETTERS DO NOT HAVE INDIVIDUAL MEANING. THEY ARE
USED FOR FORMING IDENTIFIERS AND STRINGS* (CF. SECTIONS 2.4.
IDENTIFIERS, 2.6. STRINGS).
8
<ab) : : - ( | [ | (ab) ( | (ab)(d>
SEQUENCES OF CHARACTERS ENCLOSED IN THE BRACKETS { } REPRESENT METALINGUISTIC VARIABLES WHOSE VALUES ARE SEQUENCES
OF SYMBOLS. THE MARKS ::= AND | (THE LATTER WITH THE
MEANING OF OR) ARE METALINGUISTIC CONNECTIVES. ANY MARK
IN A FORMULA, WHICH IS NOT A VARIABLE OR A CONNECTIVE,
DENOTES ITSELF (OR THE CLASS OF MARKS WHICH ARE SIMILAR TO IT).
JUXTAPOSITION OF MARKS AND/OR VARIABLES IN A FORMULA
SIGNIFIES JUXTAPOSITION OF THE SEQUENCES DENOTED. THUS THE
FORMULA ABOVE GIVES A RECURSIVE RULE FOR THE FORMATION OF
VALUES OF THE VARIABLE (AB). IT INDICATES THAT <AB> MAY
HAVE THE VALUE ( OR I OR THAT GIVEN SOME LEGITIMATE VALUE
OF <AB), ANOTHER MAY BE FORMED BY FOLLOWING IT WITH THE
CHARACTER ( OR BY FOLLOWING IT WITH SOME VALUE OF THE VARIABLE (D). IF THE VALUES OF <D) ARE THE DECIMAL DIGITS, SOME
VALUES OF (AB)ARE:
[(((1(37(
(12345<
(((
[86
NUMBERS, AND
THE REFERENCE LANGUAGE IS BUILT UP FROM THE FOLLOWING
BASIC SYMBOLS:
<baaic symbol) : : - (letter)|(digit>j{logical
value)!(delimiter)
2.1. LETTERS
A\B\C\a\E\F\G\H\
(letter)
::-
a}b|c|d|e|/|p|A|-|;|Jt|f|m|n|o|p||r|s|(|u|v|u|
' xfl/|2f
t
9
2.2.1. DIGITS
(digit) : ; - 0|l[2|3|4|5j6!7|8|9
DIGITS ARE USED FOR FORMING NUMBERS, IDENTIFIERS, AND
STRINGS.
2.2.2. LOGICAL VALUES
(logical value) : : - I r u ^ f a l a r
THE LOGICAL VALUES HAVE AFIXEDOBVIOUS MEANING.
2.3. DELIMITERS
(delimiter) : : - (operator)| (separator)! <bracket)|(declarator)|
(specificator)
(operator)
(arithmetic operator )| (relational operator)!
(logical operator)|(sequential OPERATOR)
(arithmetic operator) : : - +|-|X|/|+IT
(relational operator) : : - <|£ |-|G |> |*
(logical operator)
=p|V|AH
(sequential operator) : : - GO TO|if[then|else|FORFDO'
(separator) : : - ,|.| |:|;|:.|u|atep|untll|while|eomment
(bracket)
(|)[[|L|T|bfujinLEND
(declarator)
: : - OWN|BOOLEAN|tnteger|RE«l|»RRAY |awitch|
procedure
(specificator) : : - strlng|label|vnluc
IN ORDER TO FACILITATE THE STUDY, THE SYMBOLS USED FOR
DISTINGUISHING THE METALINGUISTIC VARIABLES (I.E. THE SEQUENCES OF CHARACTERS APPEARING WITHIN THE BRACKETS ( )
AS AB IN THE ABOVE EXAMPLE) HAVE BEEN CHOSEN TO BE WORDS
DESCRIBING APPROXIMATELY THE NATURE OF THE CORRESPONDING
VARIABLE. WHERE WORDS WHICH HAVE APPEARED IN THIS MANNER
DELIMITERS HAVE AFIXEDMEANING WHICH FOR THE MOST PART
ARE USED ELSEWHERE IN THE TEXT THEY WILL REFER TO THE CORRESPONDING SYNTACTIC DEFINITION. IN ADDITION SOME FORMULAE IS OBVIOUS OR ELSE WILL HE GIVEN AT THE APPROPRIATE PLACE
IN THE SEQUEL.
HAVE BEEN GIVEN IN MORE THAN ONE PLACE.
TYPOGRAPHICAL FEATURES SUCH AS BLANK SPACE OR CHANGE
DEFINITION:
TO
A NEW LINE HAVE NO SIGNIFICANCE IN THE REFERENCE LANGUAGE.
(empty) =
THEY MAY, HOWEVER, BE USED FREELY FOR FACILITATING READING.
(i.e. the null string of symbols).
FOR THE PURPOSE OF INCLUDING TEXT AMONG THE SYMBOLS OF
u
Btated
• Whenever the precision of arithmetic is
as being in
general not specified, or the outcome of a certain process is left
• I t should be particularly noted that throughout the reference
undefined or said to be undefined, this is to b
e interpreted in the
language underlining [in typewritten copy; boldface type in
sense that a program only fully defines a computational process
printed c o p y - E d . ] is used for defining independent basic symbols
if the accompanying information specifies the precision assumed,
(see sections 2.2.2 and 2.3). These are understood to have no relathe kind of arithmetic assumed, and the course of action to be
tion to the individual letters of which they are composed. Within
taken in all such cases as may occur during the execution of the
the present report [not including headings-Ed.], boldface will be
computation.
used for no uther purpose.
» Cf. J : W. Backus, The syntax and semantics of the proposed
' DO is used in for statements. It has no relation whatsoever
international algebraic language of the Zurich A C M - G A M M
to the do of the preliminary report, which is not included in
conference. Proc. Internal. Conf. Inf. Prnc., U N E S C O , Paris,
A L G O L 60.
June 1959.
/
AL.7a.5
KVKID ALGOL 40
a program the following '-comment" conventi
o
n
s
ly
dr
:e
2
.t
5e
.g
4e
.rshoT
p
esof type integer. AH other
I
n
a
e real (cf. section 5.1. T
ypeequiv
Declarations).
The sequence of bmictyp
tymboU:
i,
;egincomm
e
n
t
(any(anyseque
n
c
e
notnotconta
i
n
i
n
g
;); ;);
;
2
.
6
.
S
t
r
i
n
g
s end
b
c
o
m
m
e
n
t
s
e
q
u
e
n
c
e
c
o
n
t
a
i
n
i
n
g
b
e
g
i
n
e
n
d
(
a
n
y
s
e
q
u
e
n
c
e
n
o
t
c
o
n
t
a
i
n
i
n
g
e
n
d
o
r
;
o
r
e
l
s
e
)
B
yresequs
ih
va
l
e
nceinisthh
ereleft
me
a
nd
tc
to
hl
au
tmnany
of
t.
herep
t
h
r
e
e
st
r
uc2
.
6
.
1
S
y
n
t
a
x
t
u
o
w
n
e
h
a
n
m
a
y
b
e
l
a
c
e
d
,
i
n
a
n
y
os
cc
u
r
rencelineoutsi
d
eo
f
str
i
n
g
s,handbyct
h
e
ye
mr
b
o
l
s
h
o
w
n
o
n
(n
prs
o
p
s
t
r
i
nu
gt
)
:
:n
-y
(any sequence of basic symbols
t
h
e
a
m
e
i
n
t
h
e
r
i
g
h
t
o
l
u
m
w
i
t
h
o
a
'
o
r
'
»
(
e
m
p
t
y
)
e
f
f
e
ctto
n
t
ho
emmea
c
tionstru
oc
fturetheencp
r
o
ge
rr
a
m
.f
I
ts
i
s
ft
ur
t
h
e
r
u
n
d
ersto
o
d
(
ope
n
s
i
n
g
)
:
:
=
(
p
r
on
pe
r
string)|'(open string)'|
(
o
p
e
n
s
t
r
i
n
g
)
(
o
p
e
n
s
t
r
i
g
)
t
h
a
t
h
e
c
n
t
o
u
n
t
e
d
i
r
t
i
n
t
h
e
t
e
x
t
(
s
t
r
i
n
g
)ce::i
-n '
(e
oi
pe
n
string)'
w
h
e
n
r
e
a
d
i
n
g
f
r
o
m
l
e
f
t
t
o
r
i
g
h
t
h
a
s
p
r
e
c
e
d
e
n
b
n
g
replaced over later structures contained in 2t
ux
ea
nm
cp
el
.es
.h
6e
.2.seqE
2.4. Identifiers
'5k„-'[I[7W:'Tl"
2.4.1. Syntax
'.. This u is u a u 'string"
(identifier) ::- (fetter)|(identifier)(letter)|(identifier)(digit
)
2
.
6.3.order
Seman
to
icsenable the language to handl
2.4.2. Examples
I
n
t
s
e
q
u
e
n
c
e
s
ofThebasicsymbs
y
mbols
t
h
eesstr
ingspq
u
o
t
esI
1
i
n
t
r
o
d
u
c
e
d
.
o
l
u
d
e
n
o
t
a
a
c
e
.
S
o
u
p
VI 7o
sig
n
i
f
in
cg
as
ncear
oe
utsidu
esedstri
ns
gs.actual parameters of
o3ikTMNn
S
t
r
i
a
MARILYN
(t
ca
ft
.emen
st
es
ct
i
ons 3.2. Function Designators and 4.7.
2
.
4
.
3
.
S
e
m
a
n
t
i
c
s
S
)
.
I
d
e
n
t
i
f
i
e
r
s
h
a
vesim
np
oleinv
ha
er
ri
ea
nb
tles,mean
i
n
gy
,s,bul
tab2
s
e
rves
f
o
r
t
h
e
.
7
.
Q
u
a
n
t
i
t
i
e
s
,kindK
inds
anq
duantS
ci
o
p
esare disti
i
d
e
n
t
i
f
i
c
a
t
i
o
n
o
f
a
r
r
a
e
l
s
,
w
i
t
c
h
e
s
,
T
h
e
f
o
l
l
o
w
i
n
g
s
o
f
i
t
e
s
a
nc
d
proc
e
d
u
r
e
s.StT
hd
ea
yrdma
y
bo
ens).chosen freel
yimpl(
cf.,varih
o
w
es
v,er,arrays, labels, switches, and
s
e
a
b
l
se
t
i
o
n
3
.
2
.
4
.
a
n
F
u
n
c
t
i
Tr
h
e
s
c
o
pe
o
f
a tq
u
antit
y
it
sionthe
se
t
oi
fden
T
h
e
s
a
m
e
i
d
e
n
t
i
f
i
e
r
c
a
n
n
o
t
b
e
u
s
e
d
t
o
d
e
n
o
t
e
t
w
o
e
x
p
e
s
s
i
o
s
i
n
w
h
i
c
h
h
e
d
e
c
l
a
r
a
o
f
t
h
e
d
i
f
f
e
r
e
n
tsc
qo
up
ae
nt
itiea
ss ed
x
c
e
p
t
wb
h
enthe
these
q
u
a
n
t
i
t
i
eof
hh
av
eethat
c
i
a
t
e
d
w
i
t
quantity is valid. For labels
d
i
s
j
o
i
n
t
s
e
f
i
n
e
d
y
d
e
c
l
a
r
a
t
o
n
s
t
h
p
r
o
4
.
1
.
3
.
g
rc
a
m
(c5
f.
s
e
c
t
i
o
n
2s
.)7
. Quantities, Kinds 2
a.
nd
Sc
o
p
eu
se
,sandd Types
8
.
V
a
l
se
t
i
o
n
.
D
e
c
l
a
r
a
t
i
o
n
.
Agleval
u
emberi)
s, aa
nn oo
rr
dd
ee
rr
ee
dd ss
ee
ttoo
ffnl
u
m
bc
e
r
s v(
s
2
.
5
.
N
u
m
b
e
r
s
s
i
n
n
u
o
g
i
a
l
a
2s
.
S
.
Id
.i
Sn
y
n
t
a
x
c
s
en
:t
a>|of
singlt
ehelog
i
c
a
l
valuu
en
)i
,tsor
asai
l
abelt
.o
(
u
n
i
g
n
e
t
e
g
e
r)(unsi
:
:
(
d
it
gi
t
)
|
(
u|
nsign
ed(un
is
n
t
e
g
e
r)
(a
dC
ii
g
i
)
e
r
t
a
i
n
s
y
n
t
a
c
t
i
c
a
r
e
d
(int
e
g
e
r
)
:
:
g
n
e
d
i
n
e
g
e
r
)
+
i
g
n
e
d
e
g
e
r
hesethevalu
e
s
w
i
llTi
n
g
e
n
eu
re
as
lo
cf
hange
expres
ds
ui
ro
in
ns
ga
tn
(
u
n
signe
d
i
n
t
eger).(unsigned integer) T
(
d
e
c
i
m
a
l
f
r
a
c
t
i
o
n
)
o
f
p
r
o
g
r
a
m
.
h
e
v
a
l
(
ee
xc
pi
om
na
el
nt n
pu
am
rb
te
)r)::.
•
(d
intege
r
)
s
t
i
t
u
e
n
t
s
as
reth
d
enneo
drdere
id
ns
Bection 3
.val
T
h
e
vf
alueth
(d
(
u
n
s
i
g
n
e
i
n
t
e
g
e
r
)
|
(
d
e
c
i
m
a
l
f
r
a
e
t
i
o
n
)
|
i
d
e
n
t
i
f
i
e
r
i
e
e
t
o
f
u
e
s
o
(
u
n
s
i
gnednum
in
te
eg
e
r)(dcci
m
a
lf
r
a
c
t
i
o
n) number)|(expo
a
r
r
a
yeo
f
bscr"
ip
t
e
d
var
ii
an
bl
e
s
(cf.
s
ectio
n
3.
1n
.)
4.
(un
s
i
g
n
e
d
b
r
)
:
:
(
d
e
c
i
m
a
l
n
e
n
t
p
a
r
to
)s
Iu
2
.
5
.
2
.
E
x
a
m
p
l
e
s
T
h
v
a
r
i
u
s
t
y
p
e
s
"
(
t
e
g
e
r
,
r
e
a
l
,
B
o
o
l
e
a
(
d
e
c
i
m
a
l
n
u
b
e
r
)
(
e
x
p
o
n
e
n
t
p
a
r
t
)
-300
.n
0s
8i
4g
ir
«)
-|
0+
2 (
(num(
b
)gn1e
::-um
(u
ned -n.u0m8-b3ie
unsignedd
en
nt
o
ua
t
m
e
b
ec
r)!pru
on
pi
er
t
iesrefe
o
ftv
alue
s
.
Ta
hl
e
tyo
pf
estha
s
s
ocia
o
+
0e
7.
4)
3i«8
c7
ue
nr
si
b
r
s
y
c
t
i
t
s
r
o
t
h
e
v
u
e
s
e
s
e
7d
7 n
34..+10
.5m 92.ui +i.-41
0+6 3. Expressions
+0.7300
2
.
5
.
3
.
Sen
mu
am
nt
i
c
s
I
n
h
e
l
a
n
gu
a
ge
eg
ti
ht
e
primp
ar
r
y
c
onstia
tu
e
ntsari
ot
fhm
D
e
c
i
m
a
l
b
e
r
s
hs
aveat
h
e
i
r
ca
oc
n
v
e
ntibn
a
trg
m
eant
i
n
g
.cr
r
a
m
s
d
e
s
i
b
i
n
g
a
l
g
o
r
h
m
i
c
o
c
e
s
s
e
s
r
e
T
h
e
e
x
p
o
n
e
n
t
p
a
r
t
i
s
c
a
l
e
f
t
o
r
e
x
p
e
s
s
e
d
a
s
a
n
i
n
t
r
a
l
B
oe
os
l
ean,
as
n
d
desig
n
a
t
i
o
nalforex
p
rt
ea
si
sn
ions.
C
o
n
s
t
i
tuena
tr
s
power of 10.
t
h
e
e
x
p
r
e
s
i
o
n
s
,
e
x
c
e
p
t
c
e
r
d
e
l
i
m
i
t
e
r
s
,
vl
ae
lm
ue
en
st
,
nuam
b
e
rm
se
,tic,varr
ie
al
ba
lt
ei
so
,nal,funl
co
tg
ii
oc
nal,des
i
g
nator
s
,
e
a
r
y
r
i
t
h
a
n
d
s
e
q
o
p
e
r
a
t
o
r
s
.
S
i
n
c
e
t
h
e
s
y
n
t
a
c
t
i
c
d
e
f
i
n
i
t
i
o
n
o
f
b
o
t
h
and
func
t
ionexpd
e
s
i
g
n
a
t
o
rsan
cd
ontait
n
s
exp
r
e
s
s
i
o
n
s
,
theis
de
t
i
o
n
o
f
r
e
s
s
i
o
n
s
,
h
e
i
r
c
o
n
s
t
i
t
u
e
n
t
s
,
r
r
ss
is
vi
eo
.n) ::- (arithmetic expression >KBooloan expr
(e
ec
xu
p
r
e
(designational expression)
nui
AL.7H.6
KVtStD ALGOL 60
(
v
a
r
i
a
b
leva
ir
di
ea
nt
i
f
i
er)::::-(va
(
i
d
e
n
t
ifier
)
S(s-5)Temp'
e
r
a
t
u
r
)
e
:O
(P
:J
ressure:(P)
(
s
i
m
p
l
e
b
l
e
)
r
i
a
b
l
e
i
d
e
n
t
i
f
i
e
r
)
)
S
t
a
c
k
:
(
(s
su
ub
bs
sc
cr
ri
ip
pt
t el
xi
ps
re
s
sion)(subscript
(arithm
e
t
i
c
e
xpre
s
s
i
ob
n
)
(
t
)
e
x
p
r
e
s
s
i
o
n
)
|
(
s
u
s
cript list),
(
s
u
b
s
c
r
i
p
t
e
x
p
r
e
s
s
i
o
n
)
(
a
r
r
a
y
i
dentif
i
e
r
)
:.—(ar
(r
ia
dy
entifi
e
r
)
(
s
u
b
s
c
r
i
p
t
e
d
v
a
r
i
a
b
l
e
)
i
d
e
n
t
i
f
i
e
r
)!(sub
s
c
r
i
pb
tle>list)]
(variable) (simple variable)Kane-s
c
r
i
p
t
e
d
v
a
r
i
a
3.2.2. Examples
»in(a-b)
3.1. VARIABLES
3.1.1. Syntax
J{v+a,n)
R
CompileC
3.1.2. Examples
o?
l[
T
<
7n
,(
2n
]
i[«j
Xpt/2),Q[3,n,4tl
epailtm
detA
3.1.3. Semantics
A variable is a designation given to a single value. This
value may be used in expressions for forming other values
and may be changed at will by means of assignment statements (section 4.2). The type of the value of a particular
variable is defined in the declaration for the variable
itself (cf. section 5.1. Type Declarations) or for the corresponding array identifier (cf. section 5.2. Array Declarations).
3.1.4. Subscripts
3.1.4.1. Subscripted variables designate values which
are components of multidimensional arrays (cf. section
5.2. Array Declarations). Each arithmetic expression of
the subscript list occupies one subscript position of
the subscripted variable, and is called a subscript. The
complete list of subscripts is enclosed in the subscript
brackets [ ]. The array component referred to by a subscripted variable is specified by the actual numerical value
of its subscripts (cf. section 3.3. Arithmetic Expressions).
3.1.4.2. Each subscript position acts like a variable of
type integer and the evaluation of the subscript is understood to be equivalent to an assignment to this fictitious
variable (cf. section 4.2.4). The value of the subscripted
variable is defined only if the value of the subscript expression is within the subscript bounds of the array (cf.
section 5.2. Array Declarations).
3.2. FUNCTION DESIGNATORS
3.2.1. Syntax
:=
3.2.3. Semantics
Function designators define single numerical or logical
values, which result through the application of given sets
of rules defined by a procedure declaration (cf. section 5.4.
Procedure Declarations) to fixed sets of actual parameters. The rules governing specification of actual parameters are given in section 4.7. Procedure Statements. Not
every procedure declaration defines the value of a function
designator.
3.2.4. Standard functions
Certain identifiers should be reserved for the standard
functions of analysis, which will be expressed as procedures.
It is recommended that this reserved list should contain:
oo»(E) expr
fe
o
r
theEmodulus (absolute value) of t
s
s
i
o
n
siffrt(E) -1forfortheE<0
si
gn of the value of E(+l
)
»
g
r
l
(
E
) f
fo
or
rt
th
he
es
si
qn
ue
areofroot
ofvalu
te
heof
value
of
i
i
n
(
E
)
t
h
e
E
co«(E)forfor
the
c
o
s
ineval
ou
feto
hf
et
vh
ae
luearc
o
f
E
t
h
e
p
r
i
n
c
i
p
a
l
t
a
n
g
e
n
t
o
f
E
<«(E) forfor
expone
nn
at
ti
ua
rl
alfu
ln
oc
gt
ai
ro
in
thmofoftht
vu
ae
lue
thethe
eheval
arctan(E)
exp(E)
These functions are all understood to operate indifferently
on arguments both of type real and integer. They will
all yield values of type real, except for *»>n(E) which will
have values of type integer. In a particular representation these functions may be available without explicit
declarations (ef. section 5. Declarations).
3.2.5. Transfer functions
It is understood that transfer functions between any
pair of quantities and expressions may be defined. Among
the standard functions it is recommended that there be
one, namely,
enn'er(E),
which "transfers" an expression of real type to one of
integer type, and assigns to it the value which is the
largest integer not greater than the value of E.
3.3. ARITHMETIC EXPRESSIONS
3.3.1. Syntax
(
au
dl
dt
ii
np
glying
opero
ap
te
or
ra
)tor)::- +X|/||
(
m
i
(
p
r
o
c
e
d
u
r
e
i
d
e
n
t
i
f
i
e
r
)
(
i
d
e
n
t
i
f
i
e
r
)
(
p
r
i
m
a
r
y
)
=
(
u
n
s
i
g
n
e
d
n
u
m
b
e
r
)
|
(
v
a
r
i
a
b
l
e
)
|
(act(
us
aw
litchpari
a
m
e
t
e
r
)
(
s
t
r
i
n
g
)
l
(
e
x
p
r
e
s
s
i
o
n
)
!
(
a
r
r
a
y
i
d
e
n
t
i
f
i
e
r
)
!
(
f
u
n
c
t
i
o
n
d
e
s
i
g
n
a
t
o
r
)
!
(
(
a
r
i
t
h
m
e
t
i
c
e
x
p
r
e
s
s
i
o
n
))
d
e
n
t
i
f
i
e
r
>
)
(
p
r
o
c
e
d
u
r
e
i
d
e
n
t
i
f
i
e
r
)
(
f
a
c
t
o
r
)
(
p
r
i
m
a
r
y
S
(
)
f
a
c
t
o
r
)
t
(
p
r
i
m
a
r
y
>
(
l
e
t
t
er
stri
n
g
)
:
:
-(
letter>
!
(
l
c
t
t
e
r
ss
tr
i
n
g
)g
()
letter
)
.
(
ti
e
r
me
) arithm
(e
ft
ac
t
or)!(
t
ep
rm
)
(
m
ui
lo
ti
p
lying::-oper
a
te
or
rm
)(
f
actor)
(
p
a
r
a
m
e
t
e
r
d
e
l
i
m
i
t
e
r
)
=
,
|
)
(
l
e
t
t
e
r
t
r
i
n
:
(
(
s
m
p
l
i
c
e
x
r
e
s
s
n
)
(
t
)
|
(act(
ua
ac
ltualpara
m
e
t
e
r
l
i
s
t
)
=
(
a
c
t
u
a
l
p
a
r
a
m
e
t
e
r
)
\
(
ad
dd
di
in
ng
g op
oe
pe
r
a
t
or
r)>(te(
t
e)
rm )| (simple arithmetic
p
r
a
m
e
t
e
r
l
i
s
t
)
(
p
a
r
a
m
e
t
e
r
d
e
l
i
m
i
t
e
r
)
(
a
r
a
t
o
r
m
(
a
c
tualpara
pm
ae
r
a
m
eter
)art) ::- (empty)|((actual (
i
f
c
l
a
use)le
:
:s
-sion)
if (
(
B
o
o
l
e
anae
x
p
r
e
s
s
i
o
n>thee
nxpression)!
(
a
c
t
u
a
l
t
e
r
p
p
a
r
a
m
e
t
e
r
i
s
t
)
)
(
a
r
i
t
h
i
c
x
p
r
e
s
i
m
p
l
e
r
i
t
h
m
e
t
i
c
f
use)(s
m
p
l
essioa
ithmetic expression)else
(func
sa
ir
ga
nm
a
t
o
r
)p:
-t)(procedure identifier> (
(i
a
rithmc
el
ta
ic
ei
x
p
r
e
nr
)
(t
ai
co
tn
ualdep
e
t
e
r
a:
r
T'
REVISED ALGOL 4 0
3.3.2. Examples
Primaries:
7.394H-8
sunt
w(»'+2,8]
is understood). The construction:
else (simple arithmetic expression)
is equivalent to the construction:
else if true then (simple arithmetic expression)
co*(v+tX3)
(«-3/l/+i«.T8)
3.3.4. Operators and types
Apart from the Boolean expressions of if clauses, the
constituents of simple arithmetic expressions must be of
ontega
types real or integer (cf. section 5.1. Type Declarations).
The meaning of the basic operators and the types of the
7.394ui 8f toft-l-ZtSIT (A 3/y"T"fti|8)
expressions to which they lead are given by the following
rules:
3.3.4.1. The operators + , - , and X have the convenu
tional meaning (addition, subtraction, and multiplication).
The type of the expression will be integer if both of the
operands are of integer type, otherwise real.
Simple arithmetic expression:
3.3.4.2. The operations (term)/(factor) and (term) +
(factor)
both denote division, to be understood as a multiU-Yu+omegaX»um^co»(y+zX3)/7.m -8TIB[*+2,8JT
plication of the term by the reciprocal of the factor with
due regard to the rules of precedence (cf. section 3.3.5).
Arithmetic expressions:
Thus for example
Factors:
wXu-QGS+Cu)T2
if g>0 then S+3XQ/A else 2XS+3X?
if o<0 then U+V else if oXh>17 then V/V elae if
then V/U else 0
»Xain(ome0aXt)
0.57i«12Xo[WX(A/-l)/2, 0!
(AXorcfan(y)+Z)|(7+Q)
if f then n-1 else n
if a<0 then A/fl else if fc-0 then B/A else *
3.3.3. Semantics
An arithmetic expression is a rule for computing a
numerical value. In case of simple arithmetic expressions
this value is obtained by executing the indicated arithmetic operations on the actual numerical values of the
primaries of the expression, as explained in detail in
section 3.3.4 below. The actual numerical value of a
primary is obvious in the case of numbers. For variables
it is the current value (assigned last in the dynamic sense),
and for function designators it is the value arising from
the computing rules denning the procedure (cf. section
5.4.4. Values of Function Designators) when applied to
the current values of the procedure parameters given in
the expression. Finally, for arithmetic expressions enclosed in parentheses the value must through a recursive
analysis be expressed in terms of the values of primaries
of the other three kinds.
In the more general arithmetic expressions, which include if clauses, one out of several simple arithmetic expressions is selected on the basis of the actual values of the
Boolean expressions (cf. section 3.4. Boolean Expressions).
This selection is made as follows: The Boolean expressions
of the if clauses are evaluated one by one in sequence from
left to right until one having the value true is found. The
value of the arithmetic expression is then the value of
the first arithmetic expression following this Boolean
(the largest arithmetic expression found in this position
a/bx7/(p-q)Xv/s
mean?
«((oX (b-'))X7)X «P-»)-'))XP)X (»-')
The operator / is defined for all four combinations of
types real and integer and will yield results of real type
in any case. The operator
is defined only for two
operands both of type integer and will yield a result of
type integer, mathematically defined as follows:
a+b=
tign (a/b)Xentier(abl(.a/b))
(cf. sections 3.2.4 and 3.2.5).
3.3.4.3. The operation (factor)T(primary) denotes exponentiation, where the factor is the base and the primary
is the exponent. Thus, for example,
means
(2*)*
while
2T(«T"0
meane
Writing i for a number of integer type, r for a number of
real type, and a for a number of either integer or real
type, the result is given by the following rules:
off If i>0, aXaX . . . Xa (i times), of the same type as a.
If i-0, if a*0, 1, of the same type as a.
if a-0, undefined.
If »<0, if 07*0, )/(aXaX . . . Xa) (the denominator has
-i factors), of type real,
if a-0, undefined.
ajr If o>0, erp(rXMa)), of type real.
If o-O, if r>0, 0.0, of type real.
if r£0, undefined.
If a<0, always undefined.
3.3.5. Precedence of operators
The sequence of operations within one expression is
REVISED ALGOL 60
pr
i
me
aries
m
u
si
tonsbeanddecs
le
ac
rt
ei
donB5
o.
o4
l
e
a
nVa
(l
cu
fe
.s s
e
cti
T
y
p
D
e
c
l
a
r
a
t
.
4
.
o
f
g
e
n
e
r
a
l
l
y
f
r
o
m
l
e
f
t
t
o
r
i
g
h
t
,
w
i
t
h
t
h
e
f
o
l
l
o
w
i
n
g
d
d
i
t
i
o
n
a
l
De3
si
g
n
a
t
ors).
rul
e
s
:
.
4
.
5
.
Tnht
eak3
o.
p1
er
a
torsthe value true whenever
3
.
3
.
5
.
1
.
A
c
c
o
r
d
i
n
g
t
o
t
h
e
s
y
n
t
a
x
g
i
v
e
n
i
n
s
e
c
t
i
o
.
3
R
e
l
a
t
i
o
n
s
e
o
n
the following rules of precedence hold: spondingrelationis satisfied for the expressions in
e
re
wisemeaf
a
l
s
e.of the logical operators-i (not),
first: t oth
T
h
n
i
n
g
Vollow
(i
on
rg
),fu
3
(
impli
e
s
)
,
and = (equivalent), is
f
n
c
t
i
o
n
t
a
b
l
e
.
second: X/+
f
a
l
s
e
f
a
l
s
et
t
r
u
e
rl
us
e
t
h
i
r
d
:
+
¬
f
a
l
s
e
t
r
u
e
t
r
u
e
f
a
e
I
•
1
3
.
3
.
5
.
2
.
T
h
e
e
x
p
r
e
s
s
i
o
n
b
e
t
w
e
e
n
a
l
e
f
t
p
a
r
e
n
t
h
e
s
i
s
a
n
d
"
f
a
l
s
e
f
a
l
s
e
t
r
u
e
t
r
u
e
t
h
e
m
a
t
c
h
i
n
g
right
p
a
r
e
n
t
h
e
s
i
s
i
s
e
v
a
l
u
a
t
e
d
b
y
i
t
s
e
f
a
n
d
t
r
u
e
f
a
l
s
e
f
a
l
s
e
f
a
l
s
e
rn
us
e
t
r
u
e
f
l
s
e
t
r
un
etlt
t
h
i
sd
ve
as
l
u
e
isorde
u
sedofinex
se
uc
b
s
e
q
u
entofcalco
ul
a
t
i
o>
n
s
.
Ca
o
n
s
e
q
u
e
ya
t
2
f
l
e
t
r
u
e
t
r
u
e
t
r
u
e
t
h
e
i
r
e
d
r
u
t
i
o
n
p
e
r
a
i
o
n
s
w
i
t
h
i
n
f
a
l
s
e
t
r
u
e
t
r
u
e
f
a
l
s
e
e
x
p
r
e
s
s
i
o
n
c
a
n
a
l
w
a
y
s
b
e
a
r
r
a
n
g
e
d
b
y
a
p
p
r
o
p
r
i
a
e
p
o
i
,
b
l
l
3
A
.
h
4
2
.6.seqP
r
e
c
e
dence
ofopero
p
e
r
a
t
orswithin one expres
tio
n
i
n
g6.ofAritp
a
r
e
n
t
h
eseso
.f real quantities b
b
l
V
b
2
T
h
e
u
e
n
c
e
o
f
a
t
i
o
n
s
3
.
3
.
h
m
e
t
i
c
s
b
l
Z
>
l
)
2
g
e
n
e
r
a
l
l
y
f
r
o
m
l
e
f
t
t
o
right,
w
i
t
h
t
h
e
f
o
l
l
o
w
i
n
g
N
u
m
b
e
r
s
a
n
d
v
a
r
i
a
b
l
e
s
o
f
t
y
p
e
r
e
a
l
m
u
s
t
b
e
i
n
t
e
r
p
r
e
t
e
d
b
l
=
b
2
r
u
l
e
s
:
in
nheren
tt
hl
e
se
n
s
e
oo
fnlynume
ricfinite
al an
ac
lc
yu
sr
ia
sc
,y.i.eS
.imi
a
s
entit
i
e
s
dn
ef
inedto the syntax given in se
3
.
4
.
6
.
1
.
A
c
c
o
r
d
i
g
i
y
w
i
t
h
a
a
l
a
r
l
y
,
t
h
e
t
h
e
f
o
l
l
o
w
i
n
g
r
u
l
e
s
o
f
p
r
e
c
e
d
e
n
c
e
h
o
l
d
:
p
o
s
s
i
b
i
l
i
t
y
o
f
t
h
e
o
c
c
u
r
r
e
n
c
e
o
f
a
finite
d
e
v
i
a
t
i
o
n
f
r
o
m
t
h
e
ms
athema
t
il
c
a
l
l
yydeu
fn
in
e
d
r
e
s
ultNi
na
n
y
arit
h
m
e
t
i
ex
pra
e
s
s
i
o
n
fc
ir
s
t
:d
r
i
t
h
m
et
i£
c
expressions according to section 3.3.5
i
e
x
p
i
c
i
t
l
d
e
r
s
t
o
o
d
.
o
e
x
a
c
t
a
r
i
t
h
m
e
t
i
c
w
i
l
l
b
e
s
c
o
n
:
<
£
>
7
*
t
h
i
r
:
-,that
s
pf
ef
ce
i
f
i
e
d,hah
o
w
e
v
er,repa
n
dentati
t
ismayindee
ev
dalua
u
n
d
e
r
s
t
o
oh
df
o
u
r
t
h
:
A
d
i
r
e
n
t
r
d
w
a
r
e
r
e
s
i
o
n
s
t
e
a
r
i
t
fi
f
t
h
:
V
m
e
t
i
c
e
x
p
r
e
s
s
i
o
n
s
d
i
f
f
e
r
e
n
t
l
y
.
T
h
e
c
o
n
t
r
o
l
o
t
h
e
p
o
s
s
i
b
l
e
s
i
x
t
h
:
=
)
c
o
n
s
e
q
u
e
n
c
e
s
o
f
s
u
c
h
d
i
f
f
e
r
e
n
c
e
s
m
u
s
t
b
e
c
a
r
r
i
e
d
o
u
t
by
sev
e
nt
tr
ho
:l =
t
h
e
m
e
t
h
o
d
s
o
f
n
u
m
e
r
i
c
a
l
a
n
a
l
y
s
i
s
.
T
h
i
s
c
o
n
m
u
s
t
bu
ese
3
.
4
.
6
.
2
.
T
h
e
of
p
a
rent3
h
e
s
e
s
will be in
c
o
n
s
i
d
e
r
e
d
a
p
a
r
t
o
f
t
h
e
p
r
o
c
e
s
s
t
o
b
e
d
e
s
c
r
i
b
e
d
,
a
n
d
w
i
l
l
t
h
e
s
e
n
s
e
g
i
v
e
n
i
n
s
e
c
t
i
o
n
.
3
.
5
.
2
.
therefore be expressed in terms of the language itself.
3.5. Designational Expressions
3.4. Boolean Expressions
3.5.1. Syntax
3.4.1. Syntax
lw
a
b
e
l
)id
:e
:n
=tifie(
i
dentif
i
er)l(uns
i
g
n
e
dtifie
i
n
teger)
(r
re
a
t
ii
on
a
l
o
p
e
rator
)
::a
=
<
|c£|ex
=
|
So
|n
>
M(
(
s
i
t
c
h
r
)
:
:
(
i
d
e
n
r
)
(
el
l
a
t
o
n
)
:
:
{
s
i
m
p
l
e
r
i
t
h
m
e
t
i
p
r
e
s
s
i
)
(
s)
wm
ip
tl
c
hdesi
gs
ni
ag
t
o
r
)
::=expr
(s
w
i
ti
ch
i
d
entifi
e
r
)[(sub
s
c
rb
ie
pt
ex(
p
r
e
s
s
i
on)]
(
r
e
l
a
t
i
o
n
a
l
o
p
e
r
a
t
o
r
)
(
s
i
m
p
l
e
a
r
i
t
h
m
e
t
i
c
e
x
p
r
e
s
s
i
o
n
(
s
i
e
d
e
n
a
t
i
o
n
a
l
e
s
s
o
n
)
:
:
(
l
a
l
)
|
s
w
i
t
c
h
(Boo(
l
e
a
n
prim
as
r
y
)ator)!(rel
(
l
o
g
in
c)
a|
l((Boo
v
a
l
u
e>|(v
a
r
i
a
bs
ls
ei
)o
|n))(des(
(
d
e
s
i
g
n
a
t
ional
es
xs
pi
ro
en
ss
ion))(simple designational expressi
f
u
n
c
t
i
o
n
d
e
i
g
n
a
t
i
o
l
e
a
n
e
x
p
r
e
i
g
n
a
t
i
o
n
a
l
e
x
p
r
e
)
(
l
e
a
n
s
e
c
o
n
d
a
ry)::=::=(Bo(
B
o
o
l
eansec
p
r
id
ma
ar
ry
y)!)|-, (Boolean primary)
(B
Bo
oo
o
l
e
a
n
f
a
c
t
o
r
)
o
l
e
a
n
o
n
(i
frm)clause)(simple designational expression) else
(
B
o
o
leanterf
a)
ctor)
A=(Bo
o
l
e
a
n
sec
o
nt
d
a
r
y(
)
(Boo
l
e
a
n
m
:
:
(
B
o
o
l
e
a
n
f
a
c
o
r
)
!
B
o
o
l
e
a
n
t
e
Vl
(
B
o
o
l
e
a
n
f
a
ctor)(Boolean term)|(implication)Z>(Boolean(des
(
i
m
p
i
c
a
t
i
o
n
)
:
:
ti
eg
r
m
n
a>
tional expression)
(sim(
ps
li
empleBooB
lo
eo
a
n
)
:
:
~
(
i
m
p
l
i
c
a
t
i
o
n
)
!
ls
ei
an
)
*
*:
(:
im
plica
t
i
o
n
)e Boolean)|
(Boo
l
e
a
n
e
x
p
r
e
s
o
n
)
(
s
i
m
p
l
3
.
(if clause)(simple Boolean) else (Boolean exp
r
e5
s.
s2
i.
on)Examples
1
7
p
9
3.4.2. Examples
Cnooxelnll then JV else
-2z<q
y<0
i.
f Ab<c
then 17 else g[if u)£0 then
a+b
>
5
A
t-d
>
gU
3
.
5
.
3
S
e
m
a
n
t
i
c
s
pAqV
x*V«r>-,/
Aa
design
a
t
i
o
n
a
lntexp
r
e
s.
sionseci
s
a4.
ruleSta
ft
oe
rment
os
b)
ta
in
B
=
.
^
o
A
6
A
.
c
V
d
V
o
f
s
t
a
t
e
m
e
(
c
f
t
i
o
n
.
i
f
*
<1ifthen
«h
>i
o
e
lseh
g
c
pr
ri
c
i
p
l
e
tt
hs
ei
us
ae
t
i
o
n
i
s
e)
n.
tirelI
ynan
a
l
ogoug
s
i
f
i
f
a
t
e
n
6
e
l
se c thena
dn
e
l
s
eof
/xpre
h
eo
nnseva
gl(
e
l
s
e
k<k
i
t
h
m
e
t
i
c
e
s
c
t
i
o
n
3
.
3
.
3
t
h
e
en
3
.
4
.
3
.
S
e
m
a
n
t
i
c
s
t
h
e
B
o
o
l
e
a
n
e
x
p
r
e
s
s
i
o
n
s
o
f
t
h
e
i
f
.
c
l
a
u
s
e
s
A
B
o
o
l
e
a
n
e
x
p
r
e
s
s
i
o
n
i
s
a
r
u
l
e
f
o
r
c
o
m
p
u
t
i
n
g
l
o
g
i
c
a
l
i
m
p
l
e
d
e
s
ig
a
t
i
o
n
a
l
e
xpref
so
si
o
n
.. A
Ifswt
h
i
s
ie
ssigna
a
v
lue.
Thegivp
r
incip
l
e
sa
o
f
et
vi
ac
luati
o
n
ai
ro
e
es
ni
t
i
r
e
y
a
n
a
l
on
g
o
u
s
d
e
s
r
e
d
result
i
s
a
l
r
e
a
d
y
u
n
d
i
t
c
h
d
te
o
ta
o3
t
h
o
s
e
e
n
f
o
r
r
i
t
h
m
e
e
x
p
r
e
s
s
n
s
t
i
s
e
c
t
i
o
n
3
.
3
.
3
.
t
o
t
h
e
c
o
r
r
e
s
p
o
n
d
i
n
g
;
s
w
i
t
c
h
d
e
c
l
a
r
a
t
i
o
n
(
c
f
.
s
.
4
.
4
.
T
y
p
e
s
Variables and function designators entered as Boolean
X"
Y>V V
Town[it
N+l\
^f-
S
w
itch
De
c
l
a
r
a
t
it
ons)expra
ns
dionbyselet
hs
eo
an
ct
ualofnum
e
r
ical
v
a
l
u
e
REVISED ALGOL 60
o
f
i
t
s
s
u
b
s
c
r
i
p
e
s
c
t
e
t
h
e
d
e
s
i
g
n
a
t
i
o
n
a
l
e
x
p
r
e
ssiof
nr
somlis
t
e
d
io
nright.
theSis
w
i
tchthedecl
a
r
a
t
in
oa
nt
b
y
cp
or
ue
ns
ts
ii
no
g
t
h
e
s
e
l
e
f
t
t
n
c
e
d
e
s
i
g
i
o
n
a
l
e
x
n
B
l
c
k
:
t
h
u
s
s
e
l
e
c
t
e
d
m
a
y
a
g
a
i
n
b
e
a
s
w
i
t
c
h
d
e
s
i
g
n
a
t
o
r
t
h
i
s
e
le
ug
ai
-n D ; D ; .. D ;
L:SLe
:nd...vab
tio
n
i
s
o
b
v
i
o
u
s
l
y
a
r
e
c
u
r
s
i
v
e
p
r
o
c
e
s
s
.
3
.
5
.4.eval
Tu
h
e
subs
c
ripttheexpr
e
s
s
i
o
n
It
sh
o
u
l
d
b
e
k
eptcomp
il
netemin
d
t
h
ad
ts
e
a
c
h
ofo
T
h
e
a
t
i
o
n
o
f
s
u
b
s
c
r
i
p
t
e
x
p
r
e
s
s
i
o
n
i
s
n
a
l
o
g
o
u
s
m
a
y
a
g
a
i
n
b
e
a
c
o
m
p
o
u
n
t
a
t
e
m
e
n
t
t
oluethao
tf o
fss
u
b
s
c
ripte
d
v
a
r
i
ablei
ss (
c
f
.
seco
tn
io
3f
.1.4.
2h
)e
.mpls
T
hs
e
4n
.1.2i
.
E
x
a
e
s
v
a
a
w
i
t
c
h
d
e
s
i
g
n
a
t
o
r
d
e
f
i
n
e
d
l
y
t
u
b
c
ript,n,
e
x
p
r
e
s
s
i
o
n
a
s
s
u
m
e
s
o
n
e
o
f
t
h
e
p
o
s
i
t
i
v
e
v
a
l
u
e
s
1
,
2
,
3
,
.
.
.
Bh
ae
sicswis
t
a
teme
n
tt
s.
:
wh3
e.
r5
e.5.nUi
s
t
h
e
n
u
m
b
e
r
o
f
e
n
t
r
i
e
s
i
n
t
t
c
h
l
i
s
n
s
i
g
n
er
ds i
n
t
e
gersasaslabel
l
abels
o
:t
=
U
n
s
i
g
n
e
d
i
n
t
e
g
e
u
s
e
d
s
h
a
v
e
t
h
e
p
r
o
p
e
r
y
t0
ha
t
l
e
a
d
i
n
g
z
e
r
o
s
d
o
n
o
t
a
f
f
e
c
t
t
h
e
i
r
m
e
a
n
i
n
g
,
e
.
g
.
0
17
denotes the same label as 217. Compound stateme2
nt:
4. Statements
begin x := 0 ; for y := 1 step I unti
Tt
he
e
un
itsTheo
f wo
p
eratin
oo
nrmall
wy
ithin
th
e
l
a
nguac
g
e
a
r
e
c
alled
i
f
t
hen go to else if i>t
g
o
t
o
s
t
a
m
e
n
t
s
.
y
i
l
t
b
e
e
x
e
c
u
t
e
d
o
n
s
e
c
u
t
i
v
e
l
y
a
s
writt
e
n.goHowe
v
er,statt
h
ie
snts,sequw
eh
ni
ce
of
o
perat
ie
oi
nr
ss
mua
yessob
e
b
r
o
k
e
n
b
y
t
o
e
m
c
h
d
e
f
i
n
e
t
h
c
c
r
e
l
ih
citlym
,ayan
d
sho
r
t
ea
ni
en
d st
ba
ytemenc
o
nditi
o
nalbeBls
ak
t:
ep
mp
ee
nd
t.
s,
ot
c
wx
hp
i
c
c
a
u
s
e
c
e
r
t
t
s
t
o
s
k
i
Q: s
b
e
g
i
nici i
n
ty
en
ge
r
i,tekp;1 u
rn
et
ai
llwm; do
I
n
o
r
d
e
r
t
o
m
a
k
e
i
t
p
o
s
s
i
b
l
e
t
o
d
e
f
i
n
e
a
p
c
f
d
a
m
i
c
f
o
r
:«
1
s
suc
c
e
s
s
ion,
sn
tc
ae
ts
ement
s
mt
aa
y
bt
espm
ra
ov
idedbewig
tr
houpel
abelt
s
.
f
o
i
k w t+1A[i,stek]p;1 until m do
S
i
n
c
e
s
e
q
u
e
o
f
s
t
e
m
e
n
y
d
o
g
e
t
h
e
r
b
e
i
n
in
t
o
c
ompo
u
n
d
s
tc
ae
t
e
m
e
nl
ty
s ba
ndrec
bu
lr
os
ci
kv
se.th
e
def
i
n
i
t
iondeco
f
tQ| tv end for t and
s
t
a
t
e
m
e
n
t
m
u
s
t
n
e
s
s
a
r
i
e
A
l
s
o
s
i
n
c
e
l
a
e
n
d
b
l
o
c
k
r
a
t
i
o
n
s
,
d
e
s
c
r
i
b
e
d
i
n
s
e
c
t
i
o
n
5
.
e
n
t
e
r
f
u
n
d
a
m
e
n
t
a
l
l
y
i
n
t
o
4
.
1
.
3
.ofbS
e
m
aa
nt
i
c
s
t
h
e
s
y
n
t
a
c
t
i
c
s
t
r
u
c
t
u
r
e
,
t
h
e
s
y
n
t
a
c
t
i
c
d
e
f
i
n
i
t
i
o
n
s
t
e
E
v
e
r
y
l
o
c
k
a
utomai
ts
icallr
yealizi
ntroda
uc
esfol
alowsn
ewAny
l
me4
n.
t1
s. mC
uo
sm
tpoun
su
p
p
o
s
e
d
e
c
l
a
r
a
t
i
o
n
s
t
o
b
e
a
l
r
e
a
d
d
e
f
i
n
e
d
.
n
o
m
e
n
c
l
a
t
u
r
e
.
T
h
i
s
e
d
s
:
d Statements and Blocksoccurring within the block may through a suitab
4
.
1
.
1
.
S
y
n
t
a
x
t
i
o
n
(
c
f
.
s
e
c
t
i
o
n
5
.
D
e
c
l
a
r
a
t
i
o
n
s
)
b
e
s
p
e
c
i
f
i
e
d
(unla
h
e
l
l
e
d
b
a
s
i
c
s
t
a
t
e
m
e
n
t
)
:
;
=
(
a
s
s
i
g
n
m
e
n
t
s
t
a
t
e
m
e
n
t
)
!
t
o
t
h
e
b
l
o
c
k
i
n
q
u
e
s
t
i
o
n
.
T
h
i
s
m
e
a
n
s
(
a
)
(c
go s
tt
oates
t
a
t
e
ment)
\
(dummb
y
stats
et
ma
e
n
t
)nt>||
(
p
r
o
c
d
ureby
statet
m
e
n
t)identifier inside the block
r
e
p
r
s
e
n
t
e
d
h
i
s
(basi
m
e
n
t
)
(
u
n
l
a
b
e
l
e
d
a
s
i
c
t
e
m
e
(
l
a
b
e
l
)
:
b
a
s
i
c
stats
et
ma
et
ne
tm
)ent) ::'= (basic statement)!
e
x
isten
c
e
ou
te
sn
i
d
e
it,outsi
ad
n
d t(
b
)blt
h
a
tia
nycom
ep
nl
te
it
(unc(
o
n
d
i
t
i
o
n
a
l
b
y
t
h
i
s
i
d
t
i
f
i
e
r
e
h
e
o
c
k
s
t
(
c
o
m
p
o
u
n
d
s
t
a
t
e
m
e
n
t
)
!
(
b
l
o
c
k
)
s
i
b
l
e
i
n
s
i
d
e
t
h
e
b
l
o
c
k
.
(sta
t
en
m
e
n
t
)nal st(
u
n
c
o
n
d
i
t
i
o
n
a
lss
t
a
te
em
me
en
nt
t)
)!
I>
d
e
n
tifi
e
rsbl(
e
x
ceptandtho
so
et r
e
p
rn
eg
senti
n
g
l
abel
s
)to
c
(
c
o
d
i
t
i
o
a
t
e
m
e
n
t
)
!
(
f
o
r
t
a
t
w
i
t
h
i
n
a
o
c
k
n
b
e
i
d
e
c
l
a
r
e
d
t
o
h
ie
(com
p
o
u
n
d
t
a
i
l
)
:
:
(
s
t
a
t
e
m
e
n
t
)
e
n
d
|
(
s
t
a
t
e
m
e
n
;
(
c
o
m
p
o
u
n
d
t
a
i
l
)
n
o
n
l
o
c
a
l
t
o
i
t
,
i
.
e
.
w
i
l
l
r
e
p
r
e
s
e
n
t
t
h
e
s
a
m
(blo(
ck
h
et
a
d
)) :: - begi n (declaration >|s
(
b
la
oc
k
he
ad
te
hp
e
bd
lock
a)
nda;
ic
nolonthefrol
evelais
mt
me
d
i
a
t
e
l
y, oi
u.
t
s
ide
d
e
c
l
a
r
a
i
o
n
a
r
t
e
b
y
m
a
t
e
m
e
n
t
e
.
(
u
n
l
a
b
e
l
le
ed
dc
o
m
pk
o)
und) :
:
-ockbeg
i
nad)(comp
ound(co
tm
a
i
l
)
s
t
a
t
e
m
e
n
t
,
b
e
h
a
v
e
s
a
s
t
h
o
u
g
h
d
e
c
l
a
r
e
d
i
n
t
h
e
(
u
n
l
a
b
e
l
b
l
o
c
(
b
l
h
e
;
p
o
u
n
d
a
i
l
)
s
m
a
l
l
e
s
t
e
m
b
r
a
c
i
n
g
b
l
o
c
k
,
i
.
e
.
t
h
e
s
m
a
l
l
e
s
t
l
(com
p
o
ue
n
d)
s
t
ao
tm
e
m
e
n
t
)st
:a
:=
(
u)
nlahelled compound)!brackets begin and end enclose that statemenb
t
.
(
l
a
b
l
<
c
p
o
u
n
d
t
e
m
e
n
t
(
b
l
o
c
k
)
(
u
n
l
a
b
e
l
l
e
d
.
b
l
o
c
k
)
|
(
l
a
b
e
l
)
.
(
b
l
o
e
k
)
c
o
n
t
e
x
t
a
p
r
o
c
e
d
u
r
e
b
o
d
y
m
u
s
t
b
e
c
o
n
s
i
d
e
r
e
d
a
(program) ::- (block)!(compound statement) enclosed by begin and end and treated as a
S
i
nD
cec
a
se
t
t
e
m
el
ntan
od
fa
b
l
o
ckto
mayaag
a
i
n
itm
s
T
ha
i
s
s
y
n
t
a
x
m
a
yde
bc
elarat
il
l
u
ss
t,
ratedandaslaf
o
l
l
o
wst
:hb
no
on
t
i
n
g
at
r
b
i
e
c
e
p
t
s
l
o
c
a
n
o
n
l
o
c
a
l
b
l
o
c
k
t
r
r
y
s
t
a
t
e
m
e
n
t
s
,
i
o
n
b
e
l
s
,
y
t
h
e
l
t
e
r
s
t
oy
on
dta
r
e
c
u
r
s
in
vi
et
ls
y
.,ta
Tm
ha
u
soa
nma
id
entif
i
e
r,be
whicn
h
i
5
,e D
,rms:
and L, respectively, the basics
s
acti
c
u
k
e
t
o
b
l
o
c
k
A
y
r
y
n
o
t
o
n
l
o
c
a
th
fo
in4.2w
h
i
c
h
A
i
s
o
n
e
s
t
a
t
e
m
e
n
t
.
.1.AsS
sy
i
g
n
m
ent Statements
Compound statement:
4
.
2
.
n
t
a
x
(l
le
ef
ft
tp
pa
a
r
t)lis
:t
:)
-:
(
v
ariab
l
e
)t part
|)
(
p
r
o
c
e
dureP«tident
is
f
i
e
r
)f
(
r
t
:
(
l
e
f
!
(
l
e
f
t
l
i
t
)
(
l
e
L: I,: ... begin S ; S ; ...(S
;
S
d
ass
i
n
ments
a
t
)
-ean(lee
ft
a
r
tssio
l
i)
st)(arithmetic express
(
lg
ef
t
pt
a
rt
temenl
i
st)(B.
o:
ol
xp
p
r
e
n
p+q
go to Naples
CON TI $ U h t *
=
7.093
x
x+A\g\ ;
x>q
S ;
Aw: St: W :- x+bob end
AH, k] :- A\k, i] ;
A[k,
STOP
k
AL.7a.10
REVISED A L G O L 60
4.2.2.
EXAMPLES
,
=
P|0)
n
:<€=
A
:=
V A L U E IS
H/C-v-qXS
:=
:=
Z-arctan(SXzcta)
4.4.
Q>YA%
EXPRESSION
TO
ONE
OR SEVERAL
VARIABLES
OR
4.4.2.
ONLY
STEPS AS
4.4.3.
CASE B E U N D E R S T O O D TO T A K E P L A C E I N THREE
A
FOLLOWS:
THE
4.2.3.3.
THE
THE
LEFT
PART
E X P R E S S I O N O F T H E S T A T E M E N T IS
WITH
ANY
SUBSCRIPT
EXPRESSIONS
H A V I N G V A L U E S AS E V A L U A T E D I N S T E P 4 . 2 . 3 . 1 .
4.2.4.
THE
TYPES
TYPE
ASSOCIATED
W I T H ALL V A R I A B L E S
AND
PROCEDURE
IDENTIFIERS O F A LEFT PART LIST M U S T B E T H E S A M E . I F THIS T Y P E
IS
BOOLEAN,
IF
T H E T Y P E IS R E A L
ARITHMETIC.
THE
EXPRESSION
ASSOCIATED
WITH
IDENTIFIERS, APPROPRIATE
AUTOMATICALLY
INTEGER
LIKEWISE
THE
BE
BOOLEAN.
EXPRESSION
MUST
TYPE,
THE
THE
VARIABLES
AND
TRANSFER F U N C T I O N S ARE
INVOKED.
TRANSFER
FUNCTION
IS
4.5.2.
BE
REAL
TO
TO
Y I E L D A RESULT E Q U I V A L E N T TO
WHERE E
IS T H E V A L U E O F T H E
THE
TYPE
ASSO¬
C I A T E D W I T H A P R O C E D U R E IDENTIFIER IS G I V E N B Y T H E DECLARATOR
WHICH APPEARS
PROCEDURE
4.3.
GO
4.3.1.
AS T H E FIRST S Y M B O L
DECLARATION
TO
SECTION
OF THE
GO
exit
TO
4.3.3.
4.5.3.1.
TAX
BOOLEAN
OF
EXPRESSIONS.
I F STATEMENT.
T H E UNCONDITIONAL
STATEMENT
OF
TWO
CONDITIONAL
DIFFERENT
STATEMENT.
FORMS
OF
AND
STATEMENT.
A C C O R D I N G TO T H E SYN¬
CONDITIONAL
STATEMENTS
ARE
;
S4
AND
(N+11
IF BL T H E N S I ELSE IF B 2 T H E N S2 ELSE IF B3 T H E N S3
;
S4
H E R E B L TO B 3 ARE B O O L E A N E X P R E S S I O N S , W H I L E S I TO S 3
SEMANTICS
INTERRUPTS
BY
THE
SEQUENCE
OF
ARC U N C O N D I T I O N A L S T A T E M E N T S . S 4 IS T H E S T A T E M E N T F O L L O W I N G
STATEMENTS,
BY
THE
THE NORMAL
WRITE-UP
OF
TIONAL E X P R E S S I O N . T H U S T H E N E X T S T A T E M E N T TO B E
EXECUTED
CONDITIONAL
STATEMENT.
EXECUTION O F A CONDITIONAL
STATEMENT M A Y
S I N C E LABELS ARE I N H E R E N T L Y LOCAL, N O G O TO S T A T E M E N T C A N
L E A D F R O M O U T S I D E INTO A B L O C K .
A
G O TO S T A T E M E N T
INTO A C O M P O U N D
MAY,
STATEMENT.
BE
DE¬
SCRIBED AS FOLLOWS: T H E B O O L E A N E X P R E S S I O N O F T H E I F CLAUSES
E V A L U A T E D O N E AFTER T H E O T H E R I N S E Q U E N C E F R O M LEFT TO
RIGHT UNTIL O N E Y I E L D I N G T H E V A L U E T R U E IS F O U N D .
RESTRICTION
LEAD F R O M O U T S I D E
COMPLETE
THE
ARE
WILL B E T H E O N E H A V I N G THIS V A L U E AS ITS LABEL.
HOWEVER,
C A U S E C E R T A I N S T A T E M E N T S TO B E
P O S S I B L E . T H E S E M A Y B E ILLUSTRATED AS FOLLOWS:
D E F I N I N G ITS SUCCESSOR E X P L I C I T L Y B Y T H E V A L U E O F A D E S I G N A -
4.3.4.
STATEMENTS
IF BL T H E N S I ELSE IF 132 T H E N S2 ELSE S3
DEFINED
ELSE
SEMANTICS
O P E R A T I O N WILL B E C O N T I N U E D W I T H T H E N E X T
4.5.3.2.
GO LO (DESIGNATIONAL EXPRESSION)
G O TO S T A T E M E N T
OPERATIONS,
STATEMENTS
O F T H E I F CLAUSE IS T R U E . O T H E R W I S E IT WILL B E S K I P P E D
GO TO 7 W I [ I F I/<0 T H E N N ELSE A F + L J
GO TO IF Ab<c T H E N 1 7 CINE q[if w<0 T H E N 2 ELSE n]
A
SPECIFIED
THE
EXAMPLES
,
MAY
AN I F S T A T E M E N T WILL B E E X E C U T E D I F T H E B O O L E A N E X P R E S S I O N
STATEMENTS
GO TO
IT
E X E C U T E D OR S K I P P E D D E P E N D I N G O N T H E R U N N I N G V A L U E S
CORRESPONDING
5.4.4).
SYNTAX
(GO TO STATEMENT)
4.3.2.
(CF.
OPERATION.
SYNTAX
CONDITIONAL
EXPRESSION.
NO
EXAMPLES
4.5.3.
5)
enticr(E+0
EXECUTES
IF x>0 T H E N n : « N + 1
IF v>u T H E N V: G : = N + M ELSE GO TO FT
I F S < 0 V / A Q T H E N AA: B E G I N IF q<v T H E N a := v/s
ELSE y : = 2 X O E N D
ELSE IF v>& T H E N a :— v—q ELSE IF T>>8 — 1
T H E N GO TO S
UNDERSTOOD
UNDERSTOOD
STATEMENT
(IF CLAUSE) ::=« IF (BOOLEAN EXPRESSION) T H E N
(UNCONDITIONAL STATEMENT) : : = (BASIC STATEMENT)!
(COMPOUND STATEMENT)!(BLOCK)
(IF STATEMENT) :: — (IF CLAUSE) (UNCONDITIONAL STATEMENT)
(CONDITIONAL STATCMERT)
(IF STATEMENT)!(IF STATEMENT)
(STATEMENT)!(IF CLAUSE)(FOR STATEMENT)!
(LABEL) : (CONDITIONAL STATEMENT)
PROCEDURE
F O R TRANSFER F R O M
END
John:
CONDITIONAL
4.5.1.
I F T H E T Y P E O F T H E A R I T H M E T I C E X P R E S S I O N DIFFERS
F R O M THAT
TO B E
MUST
OR I N T E G E R *
;
SEMANTICS
DUMMY
4.5.
EVALUATED.
V A L U E O F T H E E X P R E S S I O N IS A S S I G N E D TO ALL
VARIABLES,
(EMPTY)
S E R V E TO P L A C E A LABEL.
PART V A R I A B L E S ARE E V A L U A T E D I N S E Q U E N C E F R O M LEFT TO RIGHT.
4.2.3.2.
::=
EXAMPLES
B E G I N ...
T H E PROCESS WILL
4 . 2 . 3 . 1 . A N Y SUBSCRIPT E X P R E S S I O N S OCCURRING I N T H E LEFT
SYNTAX
L:
OCCUR W I T H I N T H E B O D Y O F A P R O C E D U R E D E F I N I N G T H E V A L U E O F
A F U N C T I O N D E S I G N A T O R (CF. S E C T I O N 5 . 4 . 4 ) .
STATEMENTS
( D U M M Y STATEMENT)
PROCEDURE
I D E N T I F I E R S . A S S I G N M E N T TO A P R O C E D U R E IDENTIFIER M A Y
IN THE GENERAL
STATEMENT
UNDEFINED.
DUMMY
4.4.1.
SEMANTICS
A S S I G N M E N T S T A T E M E N T S S E R V E FOR A S S I G N I N G T H E V A L U E O F
AN
G O TO A N U N D E F I N E D SWITCH D E S I G N A T O R
A G O TO S T A T E M E N T IS E Q U I V A L E N T TO A D U M M Y
n+l+s
I F T H E D E S I G N A T I O N A L E X P R E S S I O N IS A SWITCH D E S I G N A T O R W H O S E
: =
4.2.3.
:=
N-F-1
S\v,k+2\
V
4.3.5.
n
UNCONDITIONAL
STATEMENT
FOLLOWING
THIS
BOOLEAN
T H E N THE
IS
EXE¬
C U T E D . U N L E S S THIS S T A T E M E N T D E F I N E S ITS SUCCESSOR E X P L I C I T L Y
THE
N E X T S T A T E M E N T TO B E E X E C U T E D WILL B E S 4 , I . E . T H E STATE-
AL.7a.ll
REVISED A L G O L 60
ment following the complete conditional statement. Thus
the effect of the delimiter else may be described by saying
that it defines the successor of the statement it follows to
be the statement following the complete conditional
statement.
The construction
E L S E (UNCONDITIONAL S T A T E M E N T )
is equivalent to
E L S E I F T R U E T H E N (UNCONDITIONAL S T A T E M E N T )
If none of the Boolean expressions of the if clauses is
true, the effect of the whole conditional statement will be
equivalent to that of a dummy statement.
For further explanation the following picture may be
useful:
f
T
I F B L T H E N S I E L S E I F B 2 T H E N S2 E L S E S3
I
^-v
B L FALSE
1 1
B 2 FALSE
;
1
84
J
tinucs with the successor of the for statement. If not, the
statement following the for clause is executed.
4.6.4. The for list elements
The for list gives a rule for obtaining the values which
are consecutively assigned to the controlled variable. This
sequence of values is obtained from the for list elements
by taking these one by one in the order in which they are
written. The sequence of values generated by each of the
three species of for list elements and the corresponding
execution of the statement S are given by the following
rules:
4.6.4.1. Arithmetic expression. This element gives rise
to one value, namely the value of the given arithmetic
expression as calculated immediately before the corresponding execution of the statement S.
4.6.4.2. Step-until-element. An element of the form
A step B until C, where A, B, and C, are arithmetic expressions, gives rise to an execution which may be described most concisely in terms of additional ALGOL
statements as follows:
V := A
;
LI: It ( V - C ) X «IFLN(B)>0 T H E N G O TO element exhausted;
STATEMENT S ;
V
V + B
;
G O T O LI ;
4.5.4. Go to into a conditional statement
The effect of a go to statement leading into a conditional
statement follows directly from the above explanation of
the effect of else.
where V is the controlled variable of the for clause and
element exhausted points to the evaluation according to
4.6. FOR S T A T E M E N T S
the next element in the for list, or if the step-until-element
4.6.1. Syntax
is the last of the list, to the next statement in the program.
(FOR LIST E L E M E N T ) : : - (ARITHMETIC EXPRESSION)!
4.6.4.3. While-element. The execution governed by a
(ARITHMETIC EXPRESSION) S T E P (ARITHMETIC EXPRESSION) U N T I L
for list element of the form E while F, where E is an
(ARITHMETIC EXPRESSION)|(ARITHMETIC EXPRESSION) W H I L E
arithmetic and F a Boolean expression, is most concisely
( B O O L E A N EXPRESSION)
(FOR LIST) : : - (FOR LIST ELEMENT>|<FOR LIST) , (FOR LIST E L E M E N T )
described in terms of additional ALGOL statements as
(FOR CLAUSE) : : - FOR (VARIABLE) : = (FOR LIST) D O
follows:
(FOR S T A T E M E N T ) : : = (FOR C L A U S E ) ( A T A T E M E N T ) |
( L A B E L ) : (FOR S T A T E M E N T )
L3: V : - E ;
I F - , F T H E N G O T O element exhausted ;
4.6.2. Examples
FOR q : = 1 S T E P « U N T I L N D O A[q] :- B[q]
FOR k : - 1 , F 1 X 2 W H I L E VKN
DO
FOR j
I+O, L, 1 S T E P 1 U N T I L JV, C+D
STATEMENT S
G O TO L3 ;
;
where the notation is the same as in 4.6.4.2 above.
4.6.5. The value of the controlled variable upon exit
Upon exit out of the statement S (supposed to be com4.6.3. Semantics
pound) through a go to statement the value of the conA for clause causes the statement S which it precedes to trolled variable will be the same as it was immediately
be repeatedly executed zero or more times. In addition it preceding the execution of the go to statement.
performs a sequence of assignments to its controlled
If the exit is due to exhaustion of the for list, on the
variable. The process may be visualized by means of the other hand, the value of the controlled variable is undefollowing picture:
fined after the exit.
4.6.6. Go to leading into a for statement
The effect of a go to statement, outside a for statement,
INITIALIZE ; TEST ; S T A T E M E N T S ; A D V A N C E ; SUCCESSOR
which refers to a label within the for statement, is undefined.
A[k,j] : - B[kJ\
r"
I
DO
i
FOR LIST EXHAUSTED
1
4.7. P R O C E D U R E S T A T E M E N T S
In this picture the word initialize means: perform the first 4.7.1. Syntax
assignment of the for clause. Advance means: perform the
(ACTUAL P A R A M E T E R ) : : = (STRING)!(EXPRESSION)!(ARRAY
next assignment of the for clause. Test determines if the
(SWITCH IDENTIFIER)!(PROCEDURE IDENTIFIER)
last assignment has been done. If so, the execution con(LETTER STRING)
(LETTER)|(LETTER STRING)(LETTER)
IDENTIFIER)!
tEVlSED ALGOL 60
(parameter delimiter) ::= ,|) (tetter strin >:(
(actual parameter list) : : - (actual parameter)!
(actual parameter list)(parameter delimiter)
(actual parameter)
(actual parameter part) : : - (empty)|
((actual parameter list))
(procedure statement) : : - (procedure identifier)
(actual parameter part)
B
4.7.2. Examples
the procedure statement and the formal parameters of the
procedure heading is established as follows: The actual
parameter list of the procedure statement must have the
same number of entries as the formal parameter list of the
procedure declaration heading. The correspondence is
obtained by taking the entries of these two lists in the
same order.
4.7.5. Restrictions
For a procedure statement to be defined it is evidently
necessary that the operations on the procedure body defined in sections 4.7.3.1 and 4.7.3.2 lead to a correct ALGOL
statement.
This imposes the restriction on any procedure statement
that the kind and type of each actual parameter be compatible with the kind and type of the corresponding formal
parameter. Some important particular cases of this general rule arc the following:
4.7.5.1. If a string is supplied as an actual parameter in
a procedure statement or function designator, whose
defining procedure body is an ALGOL 60 statement (as
opposed to non ALGOL code, cf. section 4.7.8), then this
string can only be used within the procedure body as an
actual parameter in further procedure calls. Ultimately it
can only be used by a procedure body expressed in nonALGOL code.
4.7.5.2. A formal parameter which occurs as a left part
variable in an assignment statement within the procedure
body and which is not called by value can only correspond
to an actual parameter which is a variable (special case of
expression).
4.7.5.3. A formal parameter which is used within the
procedure body as an array identifier can only correspond to an actual parameter which is an array identifier
of an array of the same dimensions. In addition if the
formal parameter is called by value the local array created
during the call will have the same subscript bounds as
the actual array.
4.7.5.4. A formal parameter which is called by value
cannot in general correspond to a switch identifier or a
procedure identifier or a string, because these latter do not
possess values (the exception is the procedure identifier of
a procedure declaration which has an empty formal
parameter part (cf. section 5.4.1) and which defines the
value of a function designator (cf. section 5.4.4). This procedure identifier is in itself a complete expression).
4.7.5.5. Any formal parameter may have restrictions
on the type of the corresponding actual parameter associated with it (these restrictions may, or may not, be
given through specifications in the procedure heading).
In the procedure statement suchrestrictionsmust evidently be observed.
4.7.6. Deleted.
4.7.7. Parameter delimiters
All parameter delimiters are understood to be equivalent. No correspondence between the parameter delimiters
used in a procedure statement and those used in the procedure heading Is expected beyond their number being the
Spur
(A)Order:
(V)
Transpose
Absmax(A,N,M, Yy,l,K)
Innerproducl(A
U,P,u],B[I'],\0,P,Y)
(7)Result to:
(TF.F+1)
These examples correspond to examples given in section
5.4.2.
4.7.3. Semantics
A procedure statement serves to invoke (call for) the
execution of a procedure body (cf. section 5.4. Procedure
Declarations). Where the procedure body is a statement
written in ALGOL the effect of this execution will be
equivalent to the effect of performing the following operations on the program at the time of execution of the procedure statement:
4.7.3.1. Value assignment (call by value)
All formal parameters quoted in the value part of the
procedure declaration heading are assigned the values
(cf. section 2.8. Values and Types) of the corresponding
actual parameters, these assignments being considered as
being performed explicitly before entering the procedure
body. The effect is as though an additional block embracing the procedure body were created in which these assignments were made to variables local to this fictitious block
with types as given in the corresponding specifications
(cf. section 5.4.5). As a consequence, variables called by
value are to be considered as nonlocal to the body of the
procedure, but local to the fictitious block (cf. section
5.4.3).
4.7.3.2. Name replacement (call by name)
Any formal parameter not quoted in the value list is
replaced, throughout the procedure body, by the corresponding actual parameter, after enclosing this latter in
parentheses wherever syntactically possible. Possible
conflicts between identifiers inserted through this process
and other identifiers already present within the procedure
body will be avoided by suitable systematic changes of the
formal or local identifiers involved.
4.7.3.3. Body replacement and execution
Finally the procedure body, modified as above, is
inserted in place of the procedure statement and executed.
If the procedure is called from a place outside the scope
of any nonlocal quantity of the procedure body the conflicts between the identifiers inserted through this process
of body replacement and the identifiers whose declarations
are valid at the place of the procedure statement or function designator will be avoided through suitable systematic
changes of the latter identifiers.
4.7.4. Actual-formal correspondence
The correspondence between the actual parameters of
REVISED ALGOL 60
name.
Thus the information conveyed by using the elaborate ones ia entirely optional.
including ssero. Integer declared variables may only assume
4.7.8. Procedure body expressed in code
positive and negative integral values including zero.
The restrictions imposed on a procedure statement
Boolean declared variables may only assume the values
calling a procedure having its body expressed in nonALGOL code evidently can only be derived from the characIn arithmetic expressions any position which can be
teristics of the code used and the intent of the user and
occupied by a real declared variable may be occupied by
thus fall outside the scope of the reference language.
an integer declared variable.
For the semantics of own, see the fourth paragraph of
5. Declarations
section 5 above.
Declarations serve to define certain properties of the
5.2. ARRAY DECLARATIONS
quantities used in the program, and to associate them with
5.2.1. Syntax
identifiers. A declaration of an identifier is valid for one
block. Outside this block the particular identifier may be
used for other purposes (cf. section 4.1.3).
DynamicaUy this implies the following: at the time of an
entry into a block (through the begin, since the labels
inside are local and therefore inaccessible from outside)
all identifiers declared for the block assume the significance implied by the nature of the declarations given.
5.2.2. Examples
If these identifiers had already been defined by other
declarations outside they are for the time being given a
new significance. Identifiers which are not declared for the
block, on the other hand, retain their old meaning.
5.2.3. Semantics
At the time of an exit from a block (through end, or by
An array declaration declares one or several identifiers
a go to statement) all identifiers which are declared for
to represent multidimensional arrays of subscripted
the block lose their local significance.
variables and gives the dimensions of the arrays, the
A declaration may be marked with the additional
bounds of the subscripts and the types of the variables.
declarator own. This has the following effect: upon a re5.2.3.1. Subscript bounds. The subscript bounds for
entry into the block, the values of own quantities will be
any
array are given in the first subscript bracket following
unchanged from their values at the last exit, while the
the
i
dentifier of this array in the form of a bound pair list.
values of declared variables which are not marked as own
Each item of this list gives the lower and upper bound of a
are undefined. Apart from labels and formal parameters
of procedure declarations and with the possible exception subscript in the form of two arithmetic expressions separated by the delimiter : The bound pair list gives the
of those for standard functions (cf. sections 3.2.4 and
3.2.5), all identifiers of a program must be declared. No bounds of all subscripts taken in order from left to right.
5.2.3.2. Dimensions. The dimensions are given as the
identifier may be declared more than once in any one
number of entries in the bound pair lists.
block head.
5.2.3.3. Types. All arrays declared in one declaration
Syntax.
are of the same quoted type. If no type declarator is
given the type
is understood.
5.2.4. Lower upper bound expressions
5.2.4.1 The expressions will be evaluated in the same
5.1. TYPE DECLARATIONS
way as subscript expressions (cf. section 3.1.4.2).
5.1.1. Syntax
5.2.4.2. The expressions can only depend on variables
and procedures which are nonlocal to the block for which
the array declaration is valid. Consequently in the outermost block of a program only array declarations with
constant bounds may be declared.
5.2.4.3. An array is defined only when the values of all
5.1.2. Examples
upper subscript bounds are not smaller than those of the
corresponding lower bounds.
5.2.4.4. The expressions will be evaluated once at each
entrance into the block.
5.2.5. The identity of subscripted variables
The identity of a subscripted variable is not related to
the subscript bounds given in the array declaration. How5.1.3. Semantics
Type declarations serve to declare certain identifiers to
represent simple variables of a given type. Real declared
variables may only assume positive or negative values
true and false.
(
l
o
w
e
r
b
o
u
n
d
)
:
:
=
(
a
r
i
t
h
m
e
t
i
c
e
x
p
r
e
s
s
i
o
n
)
(
u
p
p
e
r
b
o
u
n
d
)
:
:
=
(
a
r
i
t
h
m
e
t
i
c
e
x
p
r
e
s
s
i
o
n
) bound)
(
b
o
u
n
d
p
a
i
r
)
:
:
(
l
o
w
e
r
b
o
u
n
d
)
:
(
u
p
p
e
r
(
br
or
u
n
dp
a
ig
rmenl
i
st)::::==(bo
ur
n
d
pai
i
rn
)
|
(bou.
i
d
p
airp
(a
a
y
s
e
t
)
(
a
r
a
y
d
e
t
i
f
i
e
r
>
J
(
b
o
u
n
d
(
a
rraylisi
d
entifie
r
)
,(array
s
egme
n
tm
)
(
a
r
r
a
y
t
)
:
:
(
a
r
r
a
y
s
e
g
ent
>
|
(
a
r
raylist
l
i
s
t
)
,
(
arrayor
(arr
a
y
d
e
c
l
a
r
a
t
i
o
n
)
:
:
a
r
r
a
y
(
a
r
r
a
y
)
j
(
l
o
c
a
l
array (array list)
ar
r
ayin
a,
b,
e[7
;i
n
,
2:m],c<0*[—2
:h
1e
01
o
w
n
t
e
g
e
r
a
r
r
a
y
.
(
i
f
t
real array q[-7:-l] n 2 else
(dec
l
a
r
(
tr
ya
pt
eion)decl
n
>
|
(
a
r
rr
ae
y dd
lr
aa
r
a
t
i
on>|>
(
s
w
ia
tt
ci
hon)decl
a
|arati
(o
p
r
o
c
e
d
u
ee
cc
la
t
i
o
n
(typ
e
l
ist)variable
(
simpl,
ev
a
r
i
able)l
|ist)
(
s
i
m
p
l
e
)
(
t
y
p
e
(
t
y
p
e)or
::ow
-n r
ey
ap
le)|::Integ
e
r
|
Boo
l
e
a
ne)
(
l
o
c
a
l
t
(
t
y
p
e
)
j
o
w
n
(
t
y
p
(type declaration) (local or own type)(type list)
re-
integer p,q,»
own Boolean Acryl.n
real
AL.7a.14
W I S E D ALGOL 40
ever, even if an array is declared own the values of the 5.4.2. Examples (see also the examples at the end of
corresponding subscripted variables will, at any time, be the report)
defined only for those of these variables which have sub¬
procedure Spur(a)Order:(n)Besult:<«) ; value n ;
scripts within the most recently calculated subscript
a r r a y a ; integer n ; real s ;
bounds.
b e g i n integer k ;
5.3. S W I T C H
s
DECLARATIONS
for k
end
5.3.1. Syntax
(switch list)
(designation^ expression>|
(switch list),(designational expression)
(switchdeclaration)::- s w i t c h (switchidentifier):-(switchlist)
53.2. Examples
s w i t c h S : - ,Sl,S2.Q[m], i f t»~5
•witch
Q :~pl,w
t h e n S 3 else Si
0
;
1 step 1 u n t i l n < l < > > ; > a+<l[fc,i]
Transpose
procedure
(a)Order: (n)
array a ; i n t e g e r n ;
b e g i n real w ; integer I, k ;
for i : - 1 step 1 u n t i l n do
for k
l+i step 1 u n t i l n do
begin
; value n
w a[i,k\ ;
a[i,k] :- a[k,i} ;
a{k,i] :- w
end
end Transpose
;
5.3.3. Semantics
A switch declaration defines the set of values of the
corresponding switch designators. These values are given
one by one as the values of the designational expressions
integer procedure Step (u) ; real u ;
entered in the switch list. With each of these designational Step : - i f 0 £ u A « ^ l t h e n 1 else 0
expressions there is associated a positive integer, 1, 2, ... ,
procedure Absmaa(a)iize:{n,m)Result:(y)Subscripts:(t,*)
obtained by counting the items in the list from left to
right. The value of the switch designator corresponding to c o m m e n t The absolute greatest element of the matrix a,
of size n by m is transferred to y, and the subscripts of this
a given value of the subscript expression (cf. section 3.5.
element to t and it ;
Designational Expressions) is the value of the designaa r r a y s ; integer n, m, i , It ; real y ;
tional expression in the switch list having this given value b e g i n Integer p, q ;
as its associated integer.
y :- 0 ;
for p :- 1 step 1 u n t i l n d o for q :- 1 s t e p 1 u n t i l m d o
5.3.4. Evaluation of expressions in the switch list
I f abs(a[p,q])>y t h e n b e g i n y :- ab»(a[p,q\)
An expression in the switch list will be evaluated every
k q
time the item of the list in which the expression occurs is end end Absmax
referred to, using the current values of all variables
involved.
procedure /nnerprodueI(o,6)Order:(*;,p)Hesult:(«) ; value * ;
Integer k,p ; real y,a,b ;
5.3.5. Influence of scopes
b e g i n real « ;
If a switch designator occurs outside the scope of a
*
0 ;
quantity entering into a designational expression in the
for p
1 step 1 u n t i l k d o <
t+aXb ;
switch list, and an evaluation of this switch designator
y :— »
selects this designational expression, then the conflicts
end Innerproduct
between the identifiers for the quantities in this expression and the identifiers whose declarations are valid at the 5,43. Semantics
A procedure declaration serves to define the procedure
place of the switch designator will be avoided through
associated with a procedure identifier. The principal consuitable systematic changes of the latter identifiers.
stituent of a procedure declaration is a statement or a
5.4. P R O C E D U R E D E C L A R A T I O N S
piece of code, the procedure body, which through the use
5.4.1. Syntax
of procedure statements and/or function designators may
(formal parameter) : : - (identifier)
be activated from other parts of the block in the head of
(formal parameter list) : : - (formal parameter)!
which the procedure declaration appears. Associated with
(formal parameter list)(parameter delimiter)
the body is a heading, which specifies certain identifiers
(formal parameter)
occurring within the body to represent formal parameters.
{formal parameter part) : : - (empty)|((formal parameter list))
Formal parameters in the procedure body will, whenever
(identifier list) : : - (identifier)l(identifier list),(identifier)
(value part) : : - value (identifier list) ; | (empty)
the procedure is activated (cf. section 3.2. Function
(specifier) : : - .trlng|(type>[«rray|<type>arrayilal>el!.witcb]
Designators and section 4.7. Procedure Statements)
procedure! (type p r o c e d u r e
be assigned the values of or replaced by actual parameters.
(specification part) : : - (empty>|<speci8er)(identifier list) ; |
Identifiers in the procedure body which are not formal
(specificati on part) (spec! tier) (identifier list) ;
will be either local or nonlocal to the body depending on
(procedure heading) :: - (procedure identifier)
whether they are declared within the body or not. Those
(formal parameter part) ; (value part>(specification part)
(procedure body) :: - (statement) | (code)
of them which are nonlocal to the body may well be local
(procedure declaration) : : to the block in the head of which the procedure declarap r o c e d u r e (procedure heading>(procedure body)|
tion aorjears The procedure body always acts like a
(type) p r o c e d u r e
(procedure heading)(procedure
body)
AL.7a.15
IEVISED ALGOL 60
ifbeg
(a
b
s
(
m
n
)
<
a
b
«
(
m
[
n
)
)
)
A
(
n
<
1
6
)
thenn :- n+1
i
n
dn
:
m
n
/
2
:
mnd»end
acmncept;
e
l
s
e
:
sum :— turn + d
a ;
If abl(d$)<ept t
no(ncxtltrm
:- (+1 else t
If Ktim then gnhet
block, whether it has the form of one or not. Consequently
the scope of any label labelling a statement within the
body or the body itself can never extend beyond the procedure body. In addition, if the identifier of a formal
parameter is declared anew within the procedure body
(including the case of its use as a label as in section 4.1.3),
it is thereby given a local significance and actual parameters which correspond to it are inaccessible throughout
the scope of this inner local quantity.
end ifttlur
5.4.4. Values of function designators
For a procedure declaration to define the value of a
KK(.x,y,n,FKTw»*ta#E,VErfi) ;
function designator there must, within the procedure
fi.
x,epi,et
body, occur one or more explicit assignment statements
with the procedure identifier in a left part; at least one of
these must be executed, and the type associated with the
procedure identifier must be declared through the appearance of a type declarator as the veryfirstsymbol of the
yt(x).
procedure declaration. The last value so assigned is used FKT(x,y,nj)
to continue the evaluation of the expression in which the
function designator occurs. Any occurrence of the procedure identifier within the body of the procedure other
than in a left part in an assignment statement denotes
activation of the procedure.
5.4.5. Specifications
x-xt, xE-tmi,
k-0,
In the heading a specification part, giving information
about the kinds and types of the formal parameters by
FKT
x,y,n,
means of an obvious notation, may be included. In this
x
cemp
part no formal parameter may occur more than once.
Specifications of formal parameters called by value (cf.
section 4.7.3.1) must be supplied and specifications of
2,y\,y2,y3\\:n]
xlj2j$JI
formal parameters called by name (cf. section 4.7.3.2)
may be omitted.
RKlSTfayJl&.ye)
xjtj
5.4.6. Code as procedure body
RKiST
It is understood that the procedure body may be exx,y[k]
pressed in
language. Since it is intended that
xe-x+h
ye[k),
the use of this feature should be entirely a question of
hardwarerepresentation,no further rules concerning
RKIST
this code language can be given within the reference
language
E
xo
a
pu
lr
e
pr
cm
ed
e2."
va
i
n
t
e
g
e
r
n
;
B
o
o
l
e
a
n
;
r
e
a
l
y,yE
;
procei
dn
u
r
e
FKT
;
c
o
m
m
e
n
t
:
RK
t
e
g
r
a
t
e
s
t
h
e
syste
m
(x,snwith,]*t,
(
*
l
,
2
,
.
.
.
,
n
)
o
f
d
i
f
f
e
r
e
n
t
i
a
l
e
q
u
a
t
i
o
n
s
ho
e
K
u
t
t
a
w
i
t
h
a
u
t
o
m
a
t
i
c
s
e
a
r
c
h
f
o
r
a
p
p
r
o
p
r
i
a
t
e
l
e
n
g
t
h
s
a
r
a
rs are: T
h
e
io
ni
t
i
a
ln
values
x
at
nh
dejs
f[
*
]
kt
ne
op
w.
nP
f
u
n
cm
te
it
oe
ns
T
h
e
r
d
e
r
o
f
y
s
t
w
h
i
c
h
r
e
p
r
e
s
e
n
t
s
t
h
e
s
y
s
t
e
m
t
o
b
e
t
h
e
s
e
t
n
f
f
u
n
c
t
i
o
n
s
/
*
.
T
h
e
t
o
l
e
r
a
n
c
e
v
a
l
u
e
s
gn
ot
v
e
r
n
theinte
ar
cv
ca
u
racyxE.ofTht
heou
n
u
mu
et
ricalparam
in
t
e
g
ratio
n.whi
i
e
g
r
a
t
i
o
n
l
e
t
p
e
t
e
r
yE
s
e
n
t
*
th
e
s
o
l
ue
tn
iontha
tvx-xE.
T
hefo
B
oolea
an
v
ao
r
i
a
bd
le
a
l
w
a
y
s
b
e
g
i
v
e
a
l
u
e
t
r
u
e
r
n
i
s
l
a
t
e
RK.
Ifx,how
ever,the
functions,x„,
y mut
sh
t
betheavai
lr
ao
bc
le
edur
p
o
i
n
t
s
,z,
...
e
n
p
e
dt
le
yr (
w
il
ts
h may occur with/i-f
fo
r
1,
...com
l
a
c
a
l
a
U
e
w
h
i
c
h
e
a
v
e
s
T
herep
ir
ne
ps
u
t
para
m
e
terssetofof de
mr
u
s
t
bez[*W*(x,yUJ,
the
2
e
n
t
s
t
h
e
i
v
a
t
i
v
e
s
f
o
r
and;the actual y's. A procedure en
i
d
e
n
t
i
f
i
e
r
bea
gi
ny
m
;;real
i
n
t
e
g
e
r
;
o
w
n
r
e
a
l
t&t
procedure
; real
V
«
«
;
commen
t
:h initialin
t
e
g
r
a
tes one sinw
gl
e
RUy
N
O
E
KU
w
i
t
v
a
l
u
e
s
h
i
c
h
i
e
l
d
s
non-AiGOL
p
al
r
a
m
e
t
ersat xt. Imp
ao
nr
dtant: theth
eramet
le
at
t
er
s
o
u
t
i
o
n
p
a
r
s
enter
as nonlocal entities ;
bea
gr
ir
n
a
y:
«.[l:n|a
,a
[
l:
61:-;a[5
in
teger
*,
j
;; a[3]
a
[
l
|
[
2
|
|
:
A
/
2
:— x ;
Examples of Procedure Declarations: xt
f
o
r
it 11stes
tep!1unt
u
n
til4ndodo ye\k] :
f
o
r
,
p
i
l
beFKT(xe,xi>,nf)
gin
;
Example 1.
xe :- x+a\j] ;
p
rt
oe
cg
e
d
uretimeuler
(Jet. turn, ept, tim) ; v
a
u
e
ept,
tim
fl
o
r
*tp*
:-;
1;atep 1 until n do
i
n
e
r
;
r
e
a
l
p
r
o
c
e
d
u
r
e
fct
;
r
e
a
l
t
w
,
b
e
g
i
n
c
o
m
m
e
ntbyeider
com
p
utesat
h
e
sy
umref
o
f
fet{i) f
on
rs
i:f
r
o
m
z
e
re
o u+
pa
t
o
vlk)+aV\Xz[k]
;
i
n
f
i
n
i
t
y
m
e
a
n
s
o
f
s
u
i
t
a
b
l
e
i
n
e
d
e
u
l
e
r
t
r
a
f
o
r
m
a
t
i
o
n
.
T
b
ye[k\
ye[k]
!
j
+
l
!
X
i
l*I/3
s
u
m
m
a
t
i
o
n
i
s
s
t
o
p
p
e
d
a
s
s
o
o
n
a
s
tim
t
i
m
e
s
i
n
s
u
c
c
e
s
s
i
o
n
t
h
e
a
b
s
o
l
us
ts
et
va
l
u
eepa.
of th
eence
t,
ermsoneofsho
tu
hl
e
t
r
a
nv
si
fd
oe
rmeda
ser
i
e
s
ar
e
fo
u
n
d
tooc
b
e
•
T
h
i
s
I
t
K
p
r
o
g
r
a
m
o
n
t
ainsproc
se
o
m
efn
e
wth
id
easstep
wl
e
h
a
n
H
d
p
r
o
f
u
n
c
t
i
o
n
fct
w
i
t
h
n
e
t
o
i
d
e
a
s
o
f
S
.
G
i
l
l
,
A
s
s
o
r
e
i
n
t
e
g
e
r
a
r
g
u
m
e
n
t
,
a
n
u
p
p
e
r
b
o
u
n
d
epa,
a
n
d
a
n
i
n
t
e
g
e
r
lim.
T
h
e
d
i
f
fo
er
e
nr
ti
ia
l
e
quatiPhil.
o
inSoc.
n47au
t
o
m
a
t
i
c06c
o
mputi
n
g
o
utput
i
s
theconv
se
u
m
sumo
.
euler i
saltep
a
r
t
i
c
u
l
a
r
l
y
e
f
ficien
t
nsthe
caa
se
[
P
r
c
.
Comb.
(
1
9
5
1
)
,
1
;
a
n
d
o
r
a
s
l
o
w
l
y
r
g
e
n
t
r
d
i
v
e
r
g
e
n
t
r
n
a
t
i
n
g
s
c
e
s
;
s
o
l
u
t
i
o
n
o
f
o
r
d
i
n
a
r
y
d
i
f
f
e
r
e
n
t
i
a
l
e
q
u
a
t
i
o
n
s
w
i
t
h
d
i
g
ital
b
e
g
i
n
i
n
t
e
g
e
r
i,
k,
n,
t
;
a
r
r
a
y
m
(
0
:
1
5
J
;
r
e
a
l
m
i
l
,
mp,
da
;
m
a
c
h
i
n
e
s
,
{Fyaiagraf.
Siillsk. Lund, FSrhd
i
:
«
n
;
«
l
:
'
0
;
m
l
O
]
fct(Q) ; t
u
r
n
:
•
*
m
[
0
]
/
2
;
tdmu
su
t
b
eer
dr
e
a
r,ithowem
va
ey
r,no
tt
hatbewithoptir
e
sl
pe
ctno
nextterm: i := i-f 1 ; mn :~ fct(i) ; I
a
n
r
o
n
d
o
f
f
o
r
s
m
a
,
torbeg
kin0mpst:ep 1(mu
n
t
i
l
n
d
o
been t
(
*n
ls
)/2;; m\k]
mnested;on a computer.
mn :•=• mp endn+
mm
e
a
co
m
menw
th
:
comp(af>e,)
isthe
ad
f
REVISED ALGOL 60
o
f
i
c
h
i
s
t
h
e
a
b
s
o
l
u
t
e
v
a
l
u
e
o
f
mi
a
n
t
i
ssaehave
ofbeaenan
dadeb,equa
af
tertothetheexp
o
n
e
n
t
s
e
ndik
t
t
i
e
s
m
l
l
a
r
g
e
s
t
e
n
d
ofz3the;origi
nf
allyoutgivet
nhenpara
m
eters
a,b*
end RK\ST
;
z
i
g
o
t
o
DD;y[k
;
Begin
of
program:
f
o
r
*
:
1
s
t
e
p
1
u
n
t
i
l
n
d
o
itfi
t
h
e
n
b
e
g
i
n
H
:xE-x
;
t
:
0
e
n
d
e
l
s
e
H
:He
f:
»=6»+
tl
hen;begin
sto AA
0 ;;H ;- 2
outif Ct
f+
a2
ls
e
;:rE>0)=<ff>0) then i
t
g
o
AA:
.
0
1
X
t
f
CC:
H :-1
0s
.t
5
X
H1;untout
:o
- yf
a
lt
sj
e r;
be
g
i
n
Hs
H
;
out
:
t
r
u
e
;
H
(xE~x)/2
f
o
r
*
e
p
i
l
n
d
l
l
j
end if ;(x,y,2XH^l,yl)
go tow
t;o BBk ;:- 1 step 1 until n do
RKXST
DD:
BB:
(x,n,
f
f
,i
i2
,y2)n d
;o RKXST
(z2,y2fl&,y$) ;
end RK
forif
kRK\ST
1
s
t
e
p
1
u
n
t
l
comp(yl[k],yWUta)>*P> then go t
o CC ;
AlldefrefereF
nc
e
s
a
rethe
givenabbre
t
h
r
o
u
g
h'
secti
o
n
numb
e
r
sr
.
The
re
f
ee
rences
syntac
a
r
e
g
if
v
e
n
in(if
threa
eny)
gro
o
l
l
o
w
i
n
g
v
i
a
t
i
o
n
'
d
e
f
'
'
,
r
e
f
e
e
n
c
e
t
o
t
h
t
i
c
d
e
i
n
i
t
i
o
n
synten
F
o
l
lowin
g
t
hequ
ao
bt
be
rd
eviati
o
nt"
s
ynt"
,
r
e
f
erenc
e
setn
ootthe
ot
ce
cu
r
rences in metalinguistic form
c
e
s
a
l
r
e
a
d
y
i
n
h
e
d
e
f
g
r
o
u
p
a
r
r
e
p
e
a
d
,
text
Fols
ly
om
wi
n
g
th
e
wn
o
r
d
"
t
ext"
,gnstheother
refert
eh
nc
e
sut
oerlin
de
ef
initi
o
nr
sdsgiv
en
nt
i
n
t
h
e
te
x
tpy;arebo
T
h
e
b
a
s
i
c
b
o
l
s
r
e
p
r
e
s
e
t
e
d
b
y
B
i
a
n
n
d
d
w
o
[
i
y
p
e
w
r
i
t
t
e
n
c
o
ha
vh
eebe
ex
ea
nmple
c
ollect
d
ee
gd
innin
T
s
he
a
veatbeentheignb
or
ig
n.compiling the index.
+
,s
se
ee
e:
:m
pl
u
s
(Boo
l
e
a3
n expression), def 3.4.1 synt 3, 3.3.1, 4.2.1
,
i
n
u
s
3
.
4
.
X,
,+
se
e:sem
u:
ltipld
yivide
(
B
o
o
l
e
a
n
f
a
c
t
oarr)y,),ded
fef3.4
.
1
(
B
o
o
l
e
a
n
p
r
i
m
3
.
4
.
1
/
,
e
(
B
o
o
l
e
a
n
s
e
c
o
n
d
a
r
y
)
,
d
e
f
3
.
4.1
t
,
s
e
e
:
e
x
p
o
n
e
n
t
i
a
t
i
o
n
(
B
o
o
l
e
a
n
t
e
r
m
)
,
d
e
f
3
4
.
1
<
•
£
,
5
,
>
,
r
*
.
»
e
e
:
(
r
e
l
a
t
i
o
n
a
l
o
p
e
r
a
t
o
r
)
b
o
u
n
d
p
ai
ir
r),lis
dte)f
5
.
2
.15.2.1
•
,see3
,co
V,mma
A. -i. see: (logical operator)(
(
b
o
u
n
d
p
a
,
d
e
f
,
,
:
(bracket), def 2.3
.t,
s
e
e
:
d
e
c
imal point
i
,
s
e
e
:
t
e
n
:
,
se
ee
e:
:B
ce
om
li
oc
nolon
(c
co
ol
do
e
),:s
yntsyn5
.4.12.3,
text3.24
.
7
.8,4.16
.
4
.64.5.1, 4.6.1,
;
,
s
n
,
t
.
1
,
.
1
,
:,
-,se
se
e:
e:sp
c
o
l
on equal
c
o
lm
on
equas
lynt:-2
,.3,syn3
t.1.12
.3,3.2.
4
.
2.1,4.6.
4
.
6.1,4.7.1
5,
3
.
1
u
a
c
e
c
o
m
a
,
,
,
1
,
1
,
5
.
1.1,
(
)
,
s
e
e
:
p
a
r
e
n
t
h
e
s
e
s
c
o
m
m
e
n
t
,
s
y
n
t
2
.
3
1
see:see:
subsc
r
i
p
t
e
t
s
c
o
m
m
e
nn
tdcs
ot
na
vt
ee
nm
te
in
ot
n)
,, t
e
x
t4
2
.
3
•1,',
s
t
r
i
ngbr
qa
uc
ok
t
e
s
(
c
o
m
p
o
u
d
e
f
.
1
.1 synt 4.5.1 text 1
(
c
o
m
p
o
u
n
d
t
a
i
l
)
,
d
e
f
4
.
1
.
1
(
a
c
t
u
a
l
p
ar
ra
am
me
et
te
er
r),lisd
e
f
3
.
2
.1,3.24
.
7
.14.7.1 (conditional statement), def 4.5.1 synt 4.1.1 text 4
(
a
c
t
u
a
l
p
a
t
)
,
d
e
f
.
1
,
(
a
c
t
u
a
l
p
a
r
a
m
e
t
e
r
pa
rf
t),3.3
d.
e1
f.3.2.1, 4.7.1 (
d
e
c
i
ma
al
lf
r
a
cb
te
io
n
),, d
d
e
f2
2
.
5
.
1 text 2.5.3
(
a
d
d
i
n
g
o
p
e
r
a
t
o
r
)
,
d
e
(
d
e
c
i
m
n
u
m
r
)
e
f
.
5
.
1
a
li
pt
hh
am
be
et
t
,
te
x
t
2.
1
d
e
c
i
m
a
l
p,
ointdef.,6sy
n
t
2.
3
,.12.t
6.
1
a
r
i
c
,
t
e
x
t
3
.
3
.
6
(
d
e
c
l
a
r
a
t
i
o
n
)
s
y
n
t
4
.
1
e
xt 1, 5
(ari
t
h
m
e
t
i
c
e
x
p
r
e
s
s
i
o
n
)
,
d
e
f
3
.
3
.
1
s
y
n
t
3
,
3
.
1
.
1
,
3
.
3
.
1
,
3
.
4
.
1
,
4
.
2
.
1
,
(
d
e
c
l
a
r
a
t
o
r
)
,
d
e
f
2
.
3
(c2
omp
l
e.
t
es
sy
en
ct
tion)
4
.
6
.t
1i
,c6.
2
.
1rator
t)
e,
xtde
3f
.3.32.3 text 3.3.4 (
de
es
li
ig
mn
ia
tt
e
r
)
,
de
f
2
.i
3on),synt
(a
ar
i
t
h
m
e
o
p
e
(
d
i
o
n
a
l
e
x
p
r
e
s
s
d
e
f
3
.
5
1
3, 4.3.1.,
r
r
a
y
,
s
y
n
t
2
.
3
,
6
.
2
.
1
,
5
.
4
.
1
(
d
i
g
i
t
)
,
d
e
f
2
.
2
.
1
s
y
n
t
2
,
2
.
4
.
1
,
2
.
5
.
1
a
r
ra
a
y,det
e
x
t
3
.
1
.4.1def 5.2.1 synt 6 text 6
d
i
m
e
n
sion/
,t
e,
xts5
.
2
.3.22.3, 3.3.1 text 3.3.4.2 *
(
a
r
r
y
c
l
a
r
a
t
i
o
n
)
,
.
2
.
3
d
i
v
i
d
e
+
y
n
t
(
a
r
r
a
y
ii
de
n
t
i
fier)
,
de
f
3.1.1 synt 3.2.1, 4.7.1
,
6
.2
.
1ns
te
e2
x
t
2.8
d
o
,
s
y
ttat
.
3t
,),
4.6
.
1
(
a
r
r
a
y
l
s
t
)
,
d
e
f
5
.
2
.
1
(
d
u
m
m
y
m
e
n
d
e
f 4.4.1 synt 4.1.1 text 4.4.3
(
a
r
r
a
y
s
e
g
m
e
n
t
)
,
d
e
f
5
.
2
.
1
(assignment statement), def 4.2.1 synt 4.1.1 (
t
e
x
t
1,
4
.2.2
3.
e
l
s
e
,
s
y
n
t
3
,3
.
3
.
1,2.3
.
4
.
1,3.3
.
6
.
1,4.4
.
5
.,
14
t.
e7
x.
t1,
e
m
p
t
y
)
,
d
e
f
1
.
1
s
y
n
t
6
.
1
,
2
.
1
,
4
.
1
(
b
a
s
i
c
s
t
a
t
e
m
e
n
t
)
,
d
e
f
4
.
1
.
1
s
y
n
t
4
.
5
.
1
e
nd, synt 2.3, 4
.
1
.
13
(
ba
s
ii
cn,sys
my
bn
ot
l),2.3
d,
ef4.
21.1
entier,
t
e
x
t
.
2
.
63.3.1 text 3.3.4.3
b
e
g
e
x
p
o
n
e
n
t
i
a
t
i
o
n
T
,
a
y
n
t
2
.
3
,
(
b
l
o
c
k
)
,
d
e
f
4
.
1
.
1
s
y
n
t
4
.
6
.
1
t
e
x
t
1
,
4
.
1
.
3
,
6
ex
xp
pr
oe
ns
es
ni
ton),partd
)e
,fde
2y
.5
13
t.
e2
xt
.
37
(
bl
c
kean,
heads
)y
,ntdef
(e
3f s
n.
t
.1,2.5
4
.
.
1 text 3
B
oo
o
l
2.3,4.1.1
6.1.1 text 5.1.3 (
ALPHABETIC I N D E X OF DEFINITIONS OF C O N C E P T S A N D SYNTACTIC UNITS
AL.7a,17
(f
fa
c
te
or
),syd
e
f2
3
.
3
.
1
REVISED AtGOt 40
a
k
,
n
t
.
2
.
2
f
or
r,cls
y
n
t
2.3
,f44
..
66
..
11 text 4.6.3
r
e
aa
lt
,
syntdef2.33
,
6.1.1
tex
t
6.1.3
(
f
o
a
u
s
e
)
,
d
e
(
r
e
l
i
o
n
)
,
.
4
.
1
t
e
x
t
3
.
4
.
6
{
f
o
r
l
is
st
t),eld
e
f
4.6.1deftex4
t
4.6.t
4ext 4.6.4.1,(
r4
e.
l
a
t
i
o
n
a
ltex
o
p
e
r.
a3
t
o
r
), def 2.3, 3.4.1
(
f
o
r
l
i
e
m
e
n
t
)
,
.
C
.
1
6
.
4
.
2
,
4
.
6
.
4
s
c
o
p
e
,
t
2
.
7
{
f
o
r
m
a
l
p
a
ra
am
me
et
te
er
r),lisd
e
f
6.
4
.16.4
t.
e
xt 5.4.3 (s
e
m
i
c
o
l
o
n
s
y
n
t2.
23
.3, 4.1.1, 5.4.1
{
f
o
r
m
a
l
p
a
r
t
)
,
d
e
f
1
s
e
p
a
r
a
t
o
r
)
,
d
e
f
{
fo
o
rmalstap
a
r
a
m
e
t
e
rd
pe
af
rt),4
d1
ef s
5
.n
4.
1 4.1.1, 4
{
s
e
q
u
e
n
ti
a
l
o
p
e
r
ac
tor),
d
e
f
2
.3def 3.3.1 text 3.3.
{f
r
t
e
m
e
n
t
)
,
.
6
.
y
t
.
6
.
1
t
e
x
t
4
.
6
(
c
o
m
p
l
e
t
e
(
s
i
m
p
l
e
a
r
i
t
h
m
e
t
i
e
x
p
r
e
s
s
i
o
n
)
,
section)
(
s
i
m
p
l
e
B
os
oi
l
e
a
ni
)o
,naldef
3
.s
4.
1
(
s
i
m
p
l
e
d
e
g
n
a
t
e
x
p
r
e
s
i
o
n),syn
d
ef5.
3
.
5
.1text 2.
{fune
!
t
ori d^si!\tor^ def 3
.
2
.
.
1 6j"tit 3i3>l^ (
3
>
4
>
1
t
f
l
J
t
3
2
,
3
)
{
t
.
4
.
4
s
i
m
p
l
e
v
a
r
i
a
b
l
e
)
,
d
e
f
3
.
1
.
1
t
1
.
1
s
p
ac
c
e
u
,p
sa
yr
nt
t),2.
3
te
x
t
2.3
,xt2.6
.
3
HO to, synt 2.3, 4.3.1
(
s
p
e
i
f
i
c
a
t
i
o
n
d
e
f
5
.
4
.
1
t
e
5
.
4.5
(
s
p
e
c
i
f
i
c
a
t
o
r
)
,
d
e
f
2
.
3
(s
s
p
en
cd
if
i
e
r3
).
,3fun
dc
et
fion,6.4.1text 3.2.4, 3.2.5
(go to statement), def 4.3.1 synt 4.1.1 te
x
t
4
.
a
a
r
d
(
s
t
a
t
e
m
e
n
t
))
,t
d
f
.1
1, synt 4.6.1, 4.6.1, 6.4.
(
id
de
en
n
t
i
f
i
e
r),lisd
e
f
2.
4
.15.s
y
nt 3.1.1, 3.2.1; 3.5
.
1
,
6
.
4
.
1
ex
t4
2
4.3
s
e
c
t
i
o
n
(
i
t
i
f
i
e
r
t
)
,
d
e
f
4
.
1
s
t
a
t
e,
mentt
brac
k
e
t
,
s4
e
e.
:1
bt
ee
gx
i
n4
e
n.
d
I
f,cl
sa
yu
ns
te),2.3
,
3.
3
.
1
,
4.
5
.
1
s
t
e
p
s
y
n
t
2
.
3
,
.
6
t
.
6
4.2
(
i
f
d
e
f
3
.
3
.
1
,
4
.
5
.
1
s
y
n
t
3
.
4
.
1
,
3
.
5
.
1
e
x
t
3
.
3
.
3
,
4
.
5
.
3
.
2
s
t
r
i
n
g
,
s
y
n
t
2
.
3
,
5
.
4
.
1
{
i
f
s
t
a
t
e
m
e
n
t
)
,
d
e
f
4
.
5
.
1
t
e
x
t
4
.
5
.
3
.
1
st
tr
ri
i
n
g),quo
d
ee
fs2.
6.1',synt
3.2.2
1.
,3,4.7
.
1
text
2.6.
3
{i
in
mt
pl
i
c
ar
t,
ion),syntdef2.3
3
.4.15.1.1 text 5.1.3 (s
n
g
t
'
s
y
n
t
2
.
6
.
1
,
t
e
x
t
2
e
g
e
,
s
ub
bs
sc
c
r
i
p
t,bo
tu
ex
t
3.
1.
4
.
15.2.3.1
(l
ia
nb
te
g
e
r),syn
dt
ef2.
2.
5
.15.
t
e
xt 2.6.4
s
u
r
i
p
t
n
d
,
t
e
x
t
e
l
,
3
,
4
.
1
s
u
b
s
c
r
i
pt
ted
a
c
k
e
t
s
[de
]f, s
y
n.
t12t
.e
3
,
3
.
1
.4
1
,
3.5.1
(
le
af
b
el),pard
e
f
3.
6
.14.2
s.
y
nt 4.1.1, 4.5.1, 4.6.1(
t
e
x
t
1,br
4
.
1
.
3
s
u
b
s
c
r
i
p
v
a
r
i
a
b
l
e
)
,
3
.
1
x
t
3
.
1
.
.
1
(
l
t
t
)
,
d
e
f
1
(
s
u
bs
sc
cr
ri
ip
pt
tl
ei
xs
pt
r)
e,
ssion
)
,
d
e
f
3.1.1 synt 3.5.1
(l
e
f
t
partdeflist
)
,
d
e
fnt4.2
.
12.4.1, 3.2.1, 4.
{
s
u
b
d
e
f
3
.
1
.
1
(
l
e
t
t
e
r
)
,
2
.
1
s
y
2
,
7
.
1
s
u
c
c
ec
sh
so
r,syt
e
xt2.
43, 6.3.1, 5.4.1
(
le
t
t
e
r,st
te
rx
it
ng),4.1.
d
ef 3.2.1, 4.7.1
s
w
i
t
,
n
t
l
o
c
a
l
3
s
w
i
t
c
h
d
e
c
l
a
r
a
t
i
o
n
)
,dd
e
f3
5
.
3
.
1ts
y
n
t3.
56.3text 5.3.
{
lo
og
ci
ac
lalor
ot
w
n
typ
ef
),2.
d3
efs6
.
1
.13.
s
y
n
tt6
.
2
.1(
(
s
w
i
t
c
h
d
e
s
i
g
n
a
t
o
r
)
,
e
f
.
5
.
1
e
x
t
(
l
o
p
e
r
a
o
r
)
,
d
e
y
n
t
4
.
1
e
x
t
3
.
4
.
5
s
w
i
t
c
h
i
d
e
n
t
i
fier)
,
de
f
3.5.1 synt 3.2.1, 4.7.1,
(
l
o
g
i
c
albo
vu
an
lu
e
)
,dd
e
f5
2
.
2
.2ts
y
n
t5.
22
,
3.4.1 {
(
s
w
i
t
c
h
l
i
s
t
)
,
d
e
f
6
.
3
.
1
(
l
o
w
e
r
d
)
,
e
f
.
2
.
1
e
x
t
.
4
(
t
en
r1
m),u,defsynt3.3.1
m
il
n
u
s
-,
sys
ny
tnt2.2
3.
,3,2.3
6.
.3
1.
,
3
.e
3.
1
t.
e
x
t
3.
3
.
4
.
m
u
t
i
p
l
y
X
,
1
t
x
t
3
3
.
4
.
1
t
e
2
.3,3.3.
2.
5
.14.6.1
(
m
u
l
t
i
p
l
y
i
n
g
o
p
e
r
a
t
o
r
)
,
d
e
f
3
.
3
.
1
t
h
e
n
,
s
y
n
t
2
.
3
,
1
,
r
a
ns
f
ersy
fn
ut
nctio
n
,.2text 3.2.6
lb
oe
cr
al
te
ef
xt2.
4
.
1
.3text 2.5.3, 2.6.4 t
t
r
u
e
,
2
.
2
(n
no
unm
),
,d
5
.
1
(
ty
yp
pe
e),dec
dl
ea
fratio
6.
1
.
1ds
ynt5.1
6
.
4.1syn
te
xt52.8
(
t
n
)
,
e
f
.
1
t
text 6,1.3
(
o
p
e
n
s
t
r
i
n
g
)
,
d
e
f
2
.
6
.
1
(o
op
e
r
a
t
o
r
)
,
d
e
f
2
.
3
wn, synt 2.3, 6.1.1 text 6, 5.2.5 (type list), def 6.1.1
(
p
a
r
a
m
e
t
e
r
del
imite
r,),syd
e
f2
3.
.2
.
1,3.
4
.7
.
1
s
y
n
t
6
.
4
.
1
t
e
x
t
4
.
7
.7
(
u
n
c
o
n
d
i
i
o
n
al3b
s
t
ates
m4
e.
n7
t.
)1
,ent)d
e.
f4.1de
4
.14.1
..
11
, 4.5.1
p
a
r
e
n
t
h
e
s
e
s
(
)
n
t
3
,
2
.
1
,
3
.
3
.
1
,
3
.
4
.
1
,
.
5
.
1
,
5
(
u
n
l
a
h
e
l
l
e
d
a
s
i
c
t
a
t
e
m
,
f
t
e
x
t
3
.
3
.
6
.
2
(
u
n
l
a
b
e
l
e
d
b
l
o
c
ko)u,nd),
defdef
4.1.1
p
l
u
s
+
,
s
y
n
t
2
.
3
,
2
.
5
.
1
,
3
.
3
.
1
t
e
x
t
3
.
3
.
4
.
1
(
u
n
l
a
h
e
l
l
e
d
c
o
m
p
4
.
1.13.5.1
(p
pr
ro
ic
me
ar
y
)
,
d
e
f
3
.
3
.
1
(
u
n
s
i
g
n
e
d
i
n
t
e
g
e
r
)
,
d
e
f
2
.
6
.
1
,
d
u
re,bos
y
n
t
2
.f
3,6.
6
.
4
.1
(
un
ns
i
g
n,
edsy
nn
ut
mber2
).
,3,def
2.6.1
syn4
t.6.4.
3
.3.1
(
p
r
o
c
e
d
u
r
e
d
y
)
,
d
e
4
.
1
u
t
i
l
4
.
6
.
1
t
e
x
t
2
(
p
r
o
c
e
d
u
r
e
d
e
c
l
a
r
a
t
i
o
n
)
,
d
e
f
6
.
4
.
1
s
y
n
t
6
t
e
x
t
5
.
4
.
3
{
ua
pl
pe
r
bo
u
nt
d),2.3
de
f56
.
2
.
1 text 5.2.4
(
p
r
o
c
e
d
u
r
e
h
e
a
d
i
n
g
)
,
d
e
f
6
.
4
.
1
t
e
x
t
5
.
4
,
3
v
u
e
,
s
y
n
,
.
4
.
1
(
p
r
o
c
e
d
u
r
e
id
e
n
t
i
f
i
et
r)
),dd
ee
ff3
.
2
.
11ss
yy
nn
tt34
.
2
.
1
,(
4
.
7
,4.7
5
.
4
.t
1,2
t
e
x
t
4
7
5
.4text 4
v
a
l.
u1
e
t
e
x
.
8
,5
3
.
3
.
3
(
p
r
o
c
e
d
u
r
e
s
t
a
t
e
m
e
n
4
.
7
.
.
1
.
1
t
e
x
t
.
3
v
a
l
u
e
p
a
r
t
)
d
e
f
.
4
.
1
.
7
.
3
.
1.4.1, 4.2.1,
{
ge
rr
am),stri
d
.
1
1
e
(
v
a
r
i
a
b
l
e
)
,
d
e
f
3
.
1
.
1
s
y
n
t
3
.
3
.
1
,
3
(p
pr
ro
op
ne
gf
),4
d.
e
ft
2
.x
6t
.11
(variable identifier), def 3.1.1
iH
lE
e,Rs
yP
nO
tRT2.3, 4.6.1 text 4
.
6
,
4
.
3
END OFwhT
E
quantity, text 2.7
1
o
o
o
AL.7b.l
CHAPTER 7b
Features of ALGOL-60
which are changed in ALGOL-2 0
This section lists those aspects of the Report which do no
for ALGOL-20. The section numbers refer to the Report and page
numbers refer to this manual.
2.1 Only upper case letters are available.
2.2.2,2.3 The basic symbols indicated by underlined identifiers in
reference language (boldface in the report) are replaced in Algo
by identifiers with the same spelling. These identifiers, which
not be used for any other purpose, are referred to as "reserv
fiers". In addition, certain other reserved identifiers have been
added to Algol-20. See Chapter 2, page 3ff.
2.3 A change to a new line of input text has the same
as a blank space (except that strings may not continue beyond
a line). See Chapter 6a.
2.3 The characters *> and -r are not available. The character
=, X, * and * are available in different forms. See Chapter 2,
2.4 Identifiers may not contain spaces. However, see Chapter
page 5, for alternative punctuation.
2.5 See Chapter 2, page 6 for the range of values of me
numbers.
2.6.1 Since ALGOL-2 0 cannot distinguish between a left and ri
string quote, strings may not contain strings.
3.1.4.2 Array subscripts are truncated, not rounded, when they
evaluated.
3.3.4.2 -r is not available. See Chapter 2, page 2.
3.3.4.3 t produces a value of type real when it is applied
bination of real and integer values.
3.4 D is not available. See Chapter 2, page 8.
3.4.6.1 = has the same precedence as =.
3.5 A label may not be an unsigned integer.
4.1 ALGOL-20 defines <program>::=<unlabeled block>|<unlabeled
compound*. Thus the first character of a program must be a b
AL.7b.2
4.1.3
If the first occurrence of a label in the block in which it
is defined is as an actual parameter, it is necessary to declare it
as a label in that block head.
4.6
The controlled variable in a for statement may only be a
simple variable.
4.7.3.1
Arrays cannot be called by value.
5.2
Dynamic own arrays are not allowed.
5.4
Recursive procedures are not available.
5.4.5
All formal parameters must be specified.
AL.7c.l
CHAPTER 7c
Restrictions on ALGOL-20
to transform it into a subset of ALGOL-60
The user of ALGOL-20 may use many abilities which are not part of
ALGOL-60, since the translator at Carnegie Tech implements an extension
of the language.
If a program (or procedure) is to be sent outside of
Carnegie Tech, however, the programmer may wish to restrict himself to
those aspects of our system which are part of the standard language. To
do so, he must obey the rules given in this section.
Anything which gives a note (except for notes 1 and 2) indicates a
deviation of ALGOL-20 from ALGOL-60 and so should not be used.
All left parts in a statement must be of the same type.
Boolean variables must not occur as primaries in arithmetic expressions .
Arithmetic variables must not occur as primaries in Boolean expressions .
Go must be followed by to.
Nothing may be assumed about the initial value of a variable - including own variables.
"." is not a legal character in identifiers.
Constants may not end with a decimal point.
Variables may only be of type real, integer or Boolean.
The value of a for variable is undefined after the for statement has
run to completion.
If a unary operator follows another operator, it and its operand must
usually be surrounded by parentheses.
AL.7C.2
None of the following exist in ALGOL-60 and must not be used:
octal constants
alphanumeric string constants
step...while for-list elements
privileged identifiers (with their privileged meanings)
label declarations
nested substitutions
the operators i and *the reserved words max.,rain,and mpji
library procedures
SY statements
CO statements
WHAT
the operator = used to mean =
input/output
|| comment convention
">
/
Изтегляне
Само приятелско напомняне. Можете да видите документа точно тук. Но най-важното е, че нашият AI вече го е прочел. Той може да обясни сложни неща с прости думи, да отговори на вашите въпроси на всеки език и да ви помогне бързо да навигирате дори в най-дългите или сложни документи.
Реклама