PROGRAMMING ALGOL 68 MADE EASY
Title
...........................................................................
I
Copyright
..................................................................II
Dedication
...............................................................III
Contents
...................................................................IV
Preface
...................................................................XIV
1
Introduction
................................................1
1.1
What you will
need .................................3
1.2
Terminology
...........................................3
1.3
Values and modes
..................................4
1.4
Integers
...................................................6
1.5
Identity declarations
..............................7
1.6
Characters
.............................................11
1.7
Real numbers
........................................13
1.8
Program structure
.................................16
1.9
Comments
..............................................19
1.10
External values
......................................23
1.11
Summary
................................................24
2
Formulæ
.................................................... 27
2.1
Monadic operators
................................28
2.2
Dyadic operators
...................................29
2.3
Multiplication
........................................32
2.4
Division
...................................................35
2.5
Exponentiation
.......................................37
2.6
Mixed arithmetic
....................................39
2.7
Order of elaboration
..............................39
2.8
Changing the mode
................................40
2.9
Miscellaneous operators
.......................42
2.10
Operators using CHAR
...........................42
2.11
print revisited
.........................................43
2.12
Summary
.................................................44
3
Repetition
....................................................47
3.1
Multiples
.................................................48
3.1.1
Row-displays
.......................................49
3.1.2
Dimensions
.........................................52
3.1.3
Subscripts and bounds
.......................54
3.2
Slicing
......................................................57
3.3
Trimming
.................................................60
3.4
Printing multiples
...................................63
3.5
Operators with multiples
........................65
3.6
Ranges
.....................................................66
3.7
Program repetition
.................................67
3.8
Nested loops
............................................72
3.9
Program structure
...................................73
3.10
The FORALL loop
....................................74
3.11
Summary
..................................................75
4
Choice
...........................................................79
4.1
Boolean values .........................................80
4.2
Boolean operators
...................................80
4.3
Relational operators
................................81
4.4
Compound Boolean formula
...................85
4.5
Conditional clauses
.................................87
4.5.1
Pseudo-operators
.................................93
4.6
Multiple choice
........................................96
4.7
Summary
................................................102
5
Names
........................................................104
5.1
Assignment
............................................107
5.1.1
Copying
values ..................................110
5.1.2
Assignment operators
......................111
5.2
Assignments in formula
.......................115
5.3
Multiple names
.....................................117
5.4
Assigning to multiple names
...............118
5.4.1
Individual assignment
......................118
5.4.2
Collective assignment
......................121
5.5
Flexible names
......................................126
5.6
The mode STRING
.................................130
5.7
Reference modes in transput
...............132
5.8
Dynamic names
.....................................135
5.9
Loops revisited
......................................136
5.10
Abbreviated declarations
.....................138
5.11
Summary
................................................141
6
Routines
.....................................................143
6.1
Routines
.................................................143
6.1.1
Routine modes
...................................147
6.1.2
Multiples as parameters
..................148
6.1.3
Names as parameters
.......................148
6.1.4
The mode VOID
..................................149
6.1.5
Routines yielding names
...................150
6.1.6
Parameterless routines
.....................153
6.2
Operators
...............................................155
6.2.1
Identification of operators
................156
6.2.2
Operator usage
..................................160
6.2.3
Dyadic operators
...............................162
6.2.4
Operator symbols
..............................166
6.3
Procedures
.............................................167
6.3.1
Parameterless procedures
...............169
6.3.2
Procedures with parameters
............174
6.3.3
Procedures as parameters
................178
6.3.4
Recursion
............................................180
6.3.5
Standard procedures
.........................183
6.3.6
Other features of procedures
............184
6.4
Summary
.................................................187
7
Structures
...................................................189
7.1
Structure denotations
............................189
7.2
Field selection
.......................................193
7.3
Mode declarations
.................................197
7.4
Complex numbers
..................................201
7.5
Multiples in structures
..........................206
7.6
Rows of structures
..................................211
7.7
Transput of structures
............................213
7.8
Summary
.................................................214
8
Unions
.........................................................216
8.1
United mode declarations
.....................217
8.2
United modes in procedures
.................221
8.3
Conformity clauses
.................................224
8.4
Summary
.................................................228
9
Transput
.......................................................229
9.1
Books, channels and files
.......................230
9.2
Reading books
.........................................231
9.3
Writing to books
......................................236
9.4
String terminators
...................................239
9.5
Events
.......................................................241
9.5.1
Logical file end
....................................241
9.5.2
Physical file end
..................................244
9.5.3
Value error
...........................................244
9.5.4
Char error
............................................245
9.6
The command line
...................................247
9.7
Environment strings
...............................250
9.8
Writing reports
........................................252
9.9
Binary books
............................................256
9.10
Internal books
......................................... 261
9.11
Other transput procedures
..................... 262
9.12
Summary
...................................................263
10
Units
..............................................................265
10.1
Phrases
......................................................266
10.2
Contexts
.....................................................268
10.3
Coercions
...................................................269
10.3.1
Deproceduring
......................................271
10.3.2
Dereferencing
.......................................273
10.3.3
Weakly-dereferencing
..........................274
10.3.4
Uniting
...................................................275
10.3.5
Widening
................................................275
10.3.6
Rowing
....................................................276
10.3.7
Voiding
...................................................278
10.3.8
Legal coercions
......................................279
10.4
Enclosed clauses
........................................281
10.5
Primaries
....................................................284
10.6
Secondaries
................................................287
10.7
Tertiaries
.....................................................291
10.8
Quaternaries
...............................................291
10.9
Balancing
....................................................295
10.10
Well-formed modes
....................................299
10.11
Flexible names
...........................................304
10.12
Orthogonality
..............................................305
10.13
Summary
......................................................306
11
Advanced constructs
.......................................308
11.1
Bits, bytes and words
..................................309
11.1.1
Radix arithmetic
......................................310
11.2
The mode BITS
.............................................315
11.3
Overlapping slices
.......................................321
11.4
Completers
...................................................324
11.5
References to names
...................................327
11.6
Identity relations
..........................................331
11.7
The value NIL
................................................335
11.8
Queues
...........................................................339
11.9
The procedure add fan
.................................346
11.10
More queue procedures
...............................349
11.11
Trees
..............................................................354
11.12
Parallel programming
.................................359
11.13
Summary
.......................................................360
12 Program development
.........................................361
12.1 Writing programs
............................................362
12.1.1 Top-down
analysis .......................................364
12.1.2 Program layout
............................................ 365
12.1.3 Declarations
.................................................367
12.1.4 Procedures
....................................................367
12.1.5 Monetary values
...........................................368
12.1.6 Optimisation
.................................................372
12.1.7 Testing and debugging
................................373
12.1.8 Compilation errors
.......................................376
12.1.9 Arithmetic overflow
......................................379
12.1.10 Documentation
..............................................379
12.2 Non-canonical input
.........................................381
12.3 A simple utility
..................................................382
12.3.1 The source code
............................................383
12.3.2 Routines
........................................................ 386
12.3.3 Dry-running example
....................................388
12.3.4 ALIEN procedures
.........................................389
12.4 Summary
............................................................394
13 Standard Prelude
...................................................395
13.1 Standard modes
.................................................397
13.2 Environment enquiries
......................................399
13.2.1 Arithmetic enquiries
......................................400
13.2.2 Character set enquiries
.................................405
13.3 Standard operators
............................................407
13.3.1 Methods of description
..................................408
13.3.2 Standard priorities
........................................409
13.3.3 Operators with row operands
........................410
13.3.4 Operators with BOOL operands
....................410
13.3.5 Operators with INT operands
........................411
13.3.6 Operators with REAL operands
.................... 414
13.3.7 Operators with COMPL operands
.................418
13.3.8 Operators with mixed operands
....................420
13.3.9 Operators with BITS operands
......................421
13.3.10 Operators with CHAR operands
....................423
13.3.11 Operators with STRING operands
.................424
13.3.12 Assigning operators
.......................................426
13.3.13 Other operators
...............................................428
13.4 Standard procedures
..........................................429
13.4.1 Mathematical procedures
..............................429
13.4.2 Other procedures
............................................431
13.4.3 ALIEN declarations
........................................432
13.4.4 ALIEN routines
................................................434
13.5 a68toc extensions
................................................439
13.5.1 Modes peculiar to a68toc
................................439
13.5.2 a68toc constructs
.............................................441
13.5.3 Operators
..........................................................444
13.6 Control routines
...................................................448
13.6.1 Floating-point unit control
..............................448
13.6.2 Terminating a process
.....................................452
13.6.3 Garbage-collector control
................................453
13.7 Transput
.................................................................456
13.7.1 Transput modes
.................................................457
13.7.2 Standard channels
........................................... 458
13.7.3 Standard files
....................................................468
13.7.4 Opening files
.....................................................469
13.7.5 Closing files
.......................................................470
13.7.6 Transput routines
..............................................470
13.7.7 Interrogating files
.............................................478
13.7.8 File properties
...................................................479
13.7.9 Event routines
....................................................479
13.7.10 Conversion routines
..........................................482
13.7.11 Layout routines
..................................................485
13.8 Summary
................................................................486
A.1 Chapter
1
...................................................................487
A.2 Chapter
2
...................................................................491
A.3 Chapter
3
....................................................................495
A.4 Chapter
4
....................................................................502
A.5 Chapter
5
....................................................................507
A.6 Chapter
6
....................................................................518
A.7 Chapter
7
....................................................................526
A.8 Chapter
8
....................................................................530
A.9 Chapter
9
....................................................................533
A.10 Chapter 10
..................................................................565
A.11 Chapter 11
..................................................................569
B.1 Bibliography
..............................................................586
I.1 Index
...........................................................................588