Die Gruncllehren Cler Mathematischen Wissenschaften
Total Page:16
File Type:pdf, Size:1020Kb
Die Gruncllehren cler mathematischen Wissenschaften in Einzeldarstellungen mit besonderer Beriicksichtigung der Anwendungsgebiete Band 135 Herausgegeben von J. L. Doob . E. Heinz· F. Hirzebruch . E. Hopf . H. Hopf W. Maak . S. Mac Lane • W. Magnus. D. Mumford M. M. Postnikov . F. K. Schmidt· D. S. Scott· K. Stein Geschiiftsfiihrende Herausgeber B. Eckmann und B. L. van der Waerden Handbook for Automatic Computation Edited by F. L. Bauer· A. S. Householder· F. W. J. Olver H. Rutishauser . K. Samelson· E. Stiefel Volume I . Part a Heinz Rutishauser Description of ALGOL 60 Springer-Verlag New York Inc. 1967 Prof. Dr. H. Rutishauser Eidgenossische Technische Hochschule Zurich Geschaftsfuhrende Herausgeber: Prof. Dr. B. Eckmann Eidgenossische Tecbnische Hocbscbule Zurich Prof. Dr. B. L. van der Waerden Matbematisches Institut der Universitat ZUrich Aile Rechte, insbesondere das der Obersetzung in fremde Spracben, vorbebalten Ohne ausdriickliche Genehmigung des Verlages ist es auch nicht gestattet, dieses Buch oder Teile daraus auf photomechaniscbem Wege (Photokopie, Mikrokopie) oder auf andere Art zu vervielfaltigen ISBN-13: 978-3-642-86936-5 e-ISBN-13: 978-3-642-86934-1 DOl: 10.1007/978-3-642-86934-1 © by Springer-Verlag Berlin· Heidelberg 1967 Softcover reprint of the hardcover 1st edition 1%7 Library of Congress Catalog Card Number 67-13537 Titel-Nr. 5l1B Preface Automatic computing has undergone drastic changes since the pioneering days of the early Fifties, one of the most obvious being that today the majority of computer programs are no longer written in machine code but in some programming language like FORTRAN or ALGOL. However, as desirable as the time-saving achieved in this way may be, still a high proportion of the preparatory work must be attributed to activities such as error estimates, stability investigations and the like, and for these no programming aid whatsoever can be of help. In this respect, ALGOL, as an internationally standardized notation which avoids computer-oriented concepts, provides another advantage, not often mentioned, but one which was already the guiding principle at the very beginning of the programming language venture: indeed, a correct ALGOL program is the abstractum of a computing process for which the necessary analyses have already been performed. It is the very purpose of this Handbook to establish such abstract formulations of certain computing processes. Therefore, numerical methods given in this Hand book in the form of ALGOL procedures may be put to immediate use wherever ALGOL is known and understood; in fact, application of such a method reduces to little more than calling the corresponding procedure. This, however, requires that ALGOL programs be so designed that they are really abstract in the sense that they do not make use of special properties of a specific computer, and yet take into consideration the general characteristics of digital computation which are (among others): finite precision, finite storage, sequential arrangement of data on an external medium, and - not to be forgotten - finite speed. Proper use of the procedures published in this Handbook requires of course a thorough knowledge of the language ALGOL which is therefore described in this introductory volume. This description is not given in the style of the ALGOL reports (the most recent ones are reproduced in appendix B of this volume) but was modeled after lectures on ALGOL given at the Swiss Federal Institute of Technology, Zurich. In this way we hope to serve both the beginners as well as the more experienced numerical analyst. For reasons to be explained later in §4 of this volume, this Handbook sticks to SUBSET ALGOL 60, which is the official IFIP subset of ALGOL; in fact, all programs to be collected in this Handbook shall either be written in this SUBSET or else the deviations shall be clearly stated. Consequently the present volume describes SUBSET ALGOL 60 rather VI Preface than full ALGOL. In addition to other advantages, this restriction allows us to give a quantity-oriented description of the language, which from the standpoint of a prospective user is to be preferred over a name oriented description (which is the only possible way of describing full ALGOL). It is understood that parallel to and following the development of ALGOL, further progress in the field of programming languages (and formal languages in general) has been made. We mention how ALGOL has stimulated the construction of other algorithmic languages as well as the development of new and more efficient methods to translate them into machine code. We may furthermore mention another by-product of ALGOL, namely the introduction of methods for defining algorithmic languages concisely (e.g. the Backus notation). However, a comprehensive report on all these activities, as desirable as it might be, would be far beyond the scope of this Handbook, which is intended more as a tool for users of ALGOL than for those interested in programming languages as such. Instead, the reader is referred to Volume Ib (A. A. GRAU, U. HILL, and H. LANGMAACK: Translation of ALGOL 60. Edited by K. SAMELSON), which deals with the problem of translating ALGOL text into machine code; at the end of that volume the reader will find an extensive list of references to papers on ALGOL and related topics. The author is deeply indebted to Mr. F. T. PARKEL for his help in preparing the manuscript and for his invaluable suggestions for im proving the text, and to Mr. F. VANNOTTI for testing the ALGOL programs contained in this volume. Furthermore, the author wishes to thank Prof. Dr. E. STIEFEL of the Swiss Federal Institute of Technology for making available the use of the facilities of the computing center. Zurich, September 1966 H. RUTISHAUSER Contents Chapter I Introduction § 1. The Concept of Automatic Programming § 2. Historical Remarks on Algorithmic Languages 4 § 3. The ALGOL Conferences of 1958, 1960, 1962 5 3.1. ALGOL 58 ......... 5 3.2. ALGOL 60 ......... 7 3.3. The Rome amendments of 1962 7 § 4. ALGOL Dialects and the IFIP Subset of ALGOL 60 8 § 5. Preliminary Definition of ALGOL . 9 5.1. Arithmetic expressions and assignment statements 10 5.2. For-statements . 12 5.3. Compound statements . 12 5.4. Labels and goto-statements 13 5.5. The if-statement. 14 5.6. If-else-statements . 15 5.7. Declarations 16 5.8. Complete programs 17 Chapter II Basic Concepts § 6. Auxiliary Conventions 18 6.1. Syntactic forms 18 6.2. French quotes . 19 6.3. The ellipsis . 19 6.4. The syntactic diagram 19 6.5. Undefined situations . 20 § 7. The Basic Symbols of ALGOL 20 7.1. Set of basic symbols 20 7.2. Delimiters 21 7.3. Typography 21 7.4. Hardware representations. 21 § 8. Values ........ 24 8.1. Types of values . 24 8.2. Computer limitations. 24 8.3. Consequences of computer limitations 25 § 9. Quantities and their Names 25 9.1. Kinds of quantities. 25 9.2. Identifiers 26 9.3. Scope of a quantity 27 § 10. Numerical Constants 27 10.1. Examples of unsigned numbers 28 VIII Contents 10.2. Syntax. 28 10.3. Semantics 28 10.4. Types 28 10.5. Negative constants 29 § 11. Labels ........ 29 11.1. Syntax . 30 11.2. Source- and destination labels 30 11.3. Semantics 30 11.4. Scopes of labels 30 § 12. Strings 30 12.1. Examples . 31 12.2. Syntax .. 31 12.3. Semantics 31 § 13. Comments ... 32 13.1. The comment convention 32 13.2. Examples ..... 32 13.3. Conflicting situations. 32 Chapter III Expressions § 14. Variables 34 14.1. Examples. 35 14.2. Syntax. 35 14·3· Semantics 36 14.4. Types 36 § 15· Function Designators 36 15.1. Examples. 37 15·2. Syntax. 37 15·3· Semantics 39 15.4· Types 39 § 16. Simple Arithmetic Expressions 39 16.1. Examples . 40 16.2. Syntax. 40 16.3· Semantics 41 16.4. Type of the value of a simple arithmetic expression. 43 16·5· Confrontation of examples with conventional notation 43 § 17· Relations 43 1 7.1. Examples . 44 17.2. Syntax. 44 17.3. Semantics 44 § 18. Simple Boolean Expressions 45 18.1. Examples . 45 18.2. Syntax . 45 18.3. Semantics 46 § 19· Conditional Expressions 48 19.1. Examples . 48 19·2. Syntax of conditional arithmetic expressions 50 19.3. Semantics 50 19.4· Conditional Boolean expressions 51 Contents IX 19.5. Influence of types .............. 52 19.6. Syntax of general expressions . 52 19.7. Further examples involving conditional expressions 53 § 20. Subscript Expressions . 54 20.1. Syntax . 54 20.2. Semantics (Rounding rule for subscript expressions) 54 20.3. On the use of subscript expressions ...... 54 Chapter IV Statements §21. Assignment Statements 56 21.1. Examples. 56 21.2. Syntax. 56 21.3· Semantics 57 21.4. Influence of types 58 § 22. Sequences of Statements . 59 22.1. Examples . 59 22.2. Syntax . 59 22.3. Semantics 59 § 23. Labelled Statements 60 23.1. Examples. 60 23.2. Syntax. 61 23.3. Semantics 61 § 24. The Dummy Statement 62 24.1. Syntax. 62 24.2. Semantics 62 24.3. Examples. 62 24.4. Applications. 62 § 25· Goto-Statements 62 25·1. Examples. 62 25·2. Syntax. 63 25·3· Semantics 63 25.4· Applications 64 25·5· Closed loops . 65 § 26. Procedure Statements I 65 26.1. Examples. 65 26.2. Syntax. 66 26·3· Semantics 68 § 27· Compound Statements and Blocks 68 27.1. Examples. 68 27.2. Syntax. 69 27.3. Semantics of compound statements 70 § 28. The If-Statement 71 28.1. Examples. 71 28.2. Syntax. 72 28.3. Semantics 73 28.4. Applications 74 § 29· The If-Else-Statement. 76 29.1. Examples . 76 x Contents 29.2. Syntax . 77 29.3.