Revised Report on the Algorithmic Language Algol 68
Total Page:16
File Type:pdf, Size:1020Kb
Revised Report on the Algorithmic Language Algol 68 Edited by A. van Wijngaarden, B. J. Mailloux, J. E. L. Peck, C.H. A. Koster, M. Sintzoff, C.H. Lindsey, L. G. L. T. Maertens and R. G. Fisker This Edition, which is issued as a Supplement to ALGOL Bulletin number 47, includes all errata authorised by the ALGOL 68 Support subcommittee of IFIP WG2.l up to the end of 1978. This Report has been accepted by Working Group 2.1, reviewed by Technical Committee 2 on Programming and approved for publication by the General Assembly of the International Federation for Information Processing. Reproduction of the Report, for any purpose, but only of the whole text, is explicitly permitted without formality. CONTENTS Acknowledgements . ... 6 0. Introduction . ..... ... ... .. .. ... ... ... ... .. .. ... .... ... .. ... ... 8 0.1. Aims and principles of design....................................................... 8 0.1.l. Completeness and clarity of description................................. 9 0.1.2. Orthogonal design.................................................................. 9 0.1.3. Security................................................................................. 9 0.1.4. Efficiency.............................................................................. 9 0.2. Comparison with ALGOL 60 .. ... .. .. ... .. .. ... .. ... ... .. .. .. 10 0.3. Comparison with the language defined in 1968............................... 13 0.4. Changes in the method of description............................................ 15 PART I Preliminary definitions l. Language and metalanguage . 17 l.l. The method of description ............................................................ 17 l.l.l. Introduction .......................................................................... 17 l.l.2. Pragmatics .................... ..................................... .................. 18 1.1.3. The syntax of the strict language .......................................... 19 l.1.3.l. Protonotions .................................................................. 19 l.l.3.2. Production rules and production trees ........................... 21 l.l.3.3. Metaproduction rules and simple substitution ................ 23 l.l.3.4. Hyper-rules and consistent substitution . .. .. .. .. .. .. 25 l.1.4. The semantics ...................................................................... 26 l.l.4.l. Hypernotions, designation and envelopment ................... 27 .. 2 van Wijngaarden, et al. 1.1.4.2. Paranotions .................................................................. 27 1.1.4.3. Undefined ..................................................................... 30 1.1.5. Translations and variants .................................................... 30 1.2. General metaproduction rules ..................................................... 31 1.3. General hyper-rules . .. .. .. .. .. ... .. .. .. .. .. .. .. 33 2. The computer and the program .. ... .. ... ... .. .. .. .... ... ... .. ... .. ... ... ..... .... .... 35 2.1. Terminology ................................................................................ 36 2.1.1. Objects ................................................................................ 36 2.1.1.1. Values, locales, environs and scenes ............................. 36 2.1.1.2. Modes .. .. .. .. ... .. .... .... ... .. .. ... .. .... ... .. ... .. .. .. ... ... ... .. 37 2.1.1.3. Scopes .......................................................................... 38 2.1.2. Relationships ....................................................................... 39 2.1.3. Values ................................................................................. 39 2.1.3.1. Plain values ................................................................. 39 2.1.3.2. Names .......................................................................... 41 2.1.3.3. Structured values ......................................................... 42 2.1.3.4. Multiple values ... ... .. .... .. ... .. .. .. ... ..... ... ... .. ... .. .. ..... ... 42 2.1.3.5. Routines ... .. .. .. ....... .. ... .... .. ... .. ... ... ..... .. .. .. .. ... .. .. .... 45 2.1.3.6. Acceptability of values ................................................. 45 2.1.4. Actions .. .. .. .. .. ... .. ... .... .... .. .... ... .. .. .. .... ... ..... .... ... .. ... .. ... .. .... .. 46 2.1.4.1. Elaboration .................................................................. 46 2.1.4.2. Serial and collateral actions ......................................... 47 2.1.4.3. Initiation, completion and termination .......................... 48 2.1.5. Abbreviations ...................................................................... 49 2.2. The program ............................................................................... 51 PART II Fundamental constructions 3. Clauses ............................................................................................... 53 3.1. Closed clauses ............................................................................. 53 3.2. Serial clauses .............................................................................. 54 3.3. Collateral and parallel clauses .. .. .. .. .. .. .. .. .. .... .. .. .. .. .. 57 3.4. Choice clauses ............................................................................. 59 3.5. Loop clauses ............................................................................... 63 4. Declarations, declarers and indicators . .. .. 66 4.1. Declarations ................................................................................ 66 4.2. Mode declarations . .... .. .. .. .. .. ... ...... ... .... ... .. .. ...... .. ... .. ... ..... ... ... .. .. .. 67 4.3. Priority declarations ................................................................... 68 4.4. Identifier declarations . .. .. ... ... .. ... ... .... .. .. .. ... ... .. ... .. .. .. .. .. .. ... .. .. 68 4.5. Operation declarations ................................................................ 70 4.6. Declarers . .. .. .. .. ..... ... .... .. .. .. ... .... .. ... .. .. .... .. .. .. .. .. ... .. ... .. ... .. ... ... .. ... 71 4.7. Relationships between modes ...................................................... 74 4.8. Indicators and field selectors .. ... .... .. ... .. ..... ..... .. ... .. ... .. ... ... .... 76 ALGOL 68 Revised Report 3 5. Units .................................................................................................. 77 5.1. Syntax ........................................................................................ 77 5.2. Units associated with names ....................................................... 78 5.2.l. Assignations .. .. .. .. ... ... ... .... .. ... .. ... .. ... .. .. .... ......... ... .. ... .. .. .. 78 5.2.2. Identity relations ................................................................. 79 5.2.3. Generators ........................................................................... 80 5.2.4. Nihils ... .... .... .... .. .. .. .. .. ... ... .. ... .... ..... ... .. ... .. .. .. .. .... ... .. ... ... 82 5.3. Units associated with stowed values .. .......... ......... ................ .... ... 82 5.3.l. Selections .... .. ... .. .... .... ... ... .... ... .. ..... ... .. ... .. ... .. ..... .. ... .. .... .... 82 5.3.2. Slices .... .... .. .. .. .... .. .. ... .. .. .. ... .. ... .. .. .. ... .. ... ... .. ... .. .. .. ... .. ... ... .. 83 5.4. Units associated with routines .... ...... .. .. .................. ...... .. ... .. .. .. .... 86 5.4.l. Routine texts ....................................................................... 86 5.4.2. Formulas .. .... ... ... .... .... ... .. .. .. ... ... ... .. .... ... .. ... .. ... ... .. ... .. ... .. 87 5.4.3. Calls . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 88 5.4.4. Jumps . .. .. .. .. .. .. .. .. ... ... ... ... .. .. ... ... .. .. ... .. .. .. ... .. .. ... .. .. .. .... .. 89 5.5. Units associated with values of any mode .... ..... .. .... ..... .. .. .. .. .. .. .. 90 5.5.l. Casts . .... ... .... ... .... .. ... ... ... .. .. .. .. .. .. .. ... ... .. .. .. .. .. .. ... .... 90 5.5.2. Skips ................................................................................... 90 PART III Context dependence 6. Coercion .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 91 6.1. Coercees ..................................................................................... 91 6.2. Dereferencing ............................................................................. 93 6.3. Deproceduring ............................................................................ 94 6.4. Uniting . .... .... ... ... ... ... .. ... .. ... ... ... ...... .... .. .. ... .. .. .. .. .. ... .... ... .. ... 94 6.5. Widening .. .. .. .. .... ... ... ... .. .. ... .. .. ..... ... .... ... .. .. .. ... .. .. ... .. ... ... ... 95 6.6. Rowing .. .. .. .... ... .. .. .. .. .... .. .. ... ... .... .. ... .. .. .. ... .. .. .. ... .. ... .. ... .. ... ... 96 6.7. Voiding ....................................................................................... 97 7. Modes and nests . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 98 7 .l. Independence of properties .......................................................... 98 7.2. Identification in nests ................................................... ............... 101 7.3. Equivalence of modes ................................................................