M T S the Michigan Terminal System Volume 16: ALGOL W in MTS
Total Page:16
File Type:pdf, Size:1020Kb
M T S The Michigan Terminal System Volume 16: ALGOL W in MTS September 1980 The University of Michigan Computing Center Ann Arbor, Michigan ************************************************** * * * This obsoletes the August 1978 edition. * * * ************************************************** 1 DISCLAIMER The MTS Manual is intended to represent the current state of the Michigan Terminal System (MTS), but because the system is constantly being developed, extended, and refined, sections of this volume will become obsolete. The user should refer to the Computing_________ Center______ Newsletter,__________ Computing Center Memos, and future Updates to this volume for the latest information about changes to MTS. Copyright 1980 by the Regents of the University of Michigan. Copying is permitted for nonprofit, educational use provided that (1) each repro- duction is done without alteration and (2) the volume reference and date of publication are included. Permission to republish any portions of this manual should be obtained in writing from the Director of the University of Michigan Computing Center. 2 MTS 16: ALGOL W in MTS September 1980 PREFACE_______ The software developed by the Computing Center staff for the operation of the high-speed processor computer can be described as a multiprogramming supervisor that handles a number of resident, reentrant programs. Among them is a large subsystem, called MTS (Michigan Terminal System), for command interpretation, execution control, file management, and accounting maintenance. Most users interact with the computer’s resources through MTS. The MTS Manual is a series of volumes that describe in detail the facilities provided by the Michigan Terminal System. Administrative policies of the Computing Center and the physical facilities provided are described in a separate publication entitled Introduction_____________________ to the Computing________________ Center. The MTS volumes now in print are listed below. The date indicates the most recent edition of each volume; however, since volumes are updated by means of CCMemos, users should check the Memo List, copy the files *CCMEMOS or *CCPUBLICATIONS, or watch for announcements in the Computing____________________________ Center Newsletter, to ensure that their MTS volumes are fully up to date. Volume 1: The____________________________ Michigan Terminal System, December 1979 Volume 2: Public________________________ File Descriptions, December 1978 Volume 3: System______________________________ Subroutine Descriptions, October 1976 Volume 4: Terminals___________________ and Tapes, August 1974 Volume 5: System_______________ Services, April 1980 Volume 6: FORTRAN______________ in MTS, December 1978 Volume 7: PL/I___________ in MTS, July 1977 Volume 8: LISP____________________ and SLIP in MTS, June 1976 Volume 9: SNOBOL4______________ in MTS, September 1975 Volume 10: BASIC____________ in MTS, September 1974 Volume 11: Plot_______________________ Description System, August 1978 Volume 12: PIL/2____________ in MTS, December 1974 Volume 14: 360/370_________________________ Assemblers in MTS, August 1978 Volume 15: FORMAT__________________ and TEXT360, April 1977 Volume 16: ALGOL______________ W in MTS, September 1980 Other volumes are in preparation. The numerical order of the volumes does not necessarily reflect the chronological order of their appearance; however, in general, the higher the number, the more specialized the volume. Volume 1, for example, introduces the user to MTS and describes in general the MTS operating system, while Volume 10 deals exclusively with BASIC. 3 MTS 16: ALGOL W in MTS September 1980 The attempt to make each volume complete in itself and reasonably independent of others in the series naturally results in a certain amount of repetition. Public file descriptions, for example, may appear in more than one volume. However, this arrangement permits the user to buy only those volumes that serve his or her immediate needs. Richard A. Salisbury General Editor 4 MTS 16: ALGOL W in MTS September 1980 PREFACE____________________ TO VOLUME 16 Algol W is a general-purpose programming language which is a development of Algol 60. The main differences concern: Character handling Complex arithmetic A more convenient ’while’ construct A simpler ’for’ loop The ’case’ construct Data structures (using ’record’ and ’reference’) Note that Algol W is not a superset of Algol 60; Algol 60 programs cannot be compiled and run in Algol W without considerable editing. This manual describes the Algol W language, the Algol W compiler, and aspects of MTS relevant to the use of the Algol W compiler. It is intended for use as a reference manual. It is not meant for teaching programming concepts. The text does not assume a great deal of programming experience, and thus is appropriate for even the beginner. Blanche Grosswald wrote the major portion of this volume. She is grateful to members of the University of Michigan Computing Center staff and to people in the department of Computer and Communication Sciences at the University of Michigan, who read drafts of this volume, offered suggestions and examples, and pointed out ways to clarify many topics. Alan Hunter revised the text in the light of developments to Algol W at the University of Newcastle upon Tyne. This has added sections on the input/output system, external subroutine linkages, other new prede- clared procedures, and new features provided by the compiler. The main text describing the Algol W language has been modified only very slightly. NUMAC wishes to thank the University of Michigan for the use of their MTS Volume 16 text, and the University of Alberta for use of other material. The system changes for this version of Algol W were designed and coded by Alan Hunter, Margaret Hindmarsh (of Newcastle University Computing Laboratory), and James Bodwin (of the University of Michigan Computing Center). Thanks are due to members of staff of several MTS installations, in particular James Eve, Peter King and John Lloyd (of Newcastle); George Helffrich (of Michigan); Kathryn Ward, Tony Marsland and Antoine Verheijen (of the University of Alberta). Without their help, advice, and encouragement, enhancements to the Algol W system would not have been possible. 5 MTS 16: ALGOL W in MTS September 1980 6 MTS 16: ALGOL W in MTS September 1980 Contents________ Preface . 3 Reference . 39 Preface to Volume 16 . 5 Arithmetic Expressions and Assignment Statements . 41 Introduction to Algol W . 13 Expressions . 41 Terminology . 13 Assignment Statements . 44 Notation for Describing Multiple Assignment the Algol W Language . 13 Statements . 45 Basic Symbols in Algol W . 13 Precedence . 45 Format . 13 Tables of Resulting Types . 46 Presentation of Examples Assignment Compatibility . 48 in this Manual . 14 Predeclared Functions . 50 Block Structure . 15 Real to Integer Order . 16 Conversion Functions . 51 Scope . 16 Floating Point Conversion Simple Input and Output . 17 Functions . 51 Output of Real Numbers . 19 Roots and Powers Functions 52 Comments . 20 Trigonometric Functions . 52 Example Programs . 21 Inverse Trigonometric Example Program 1 . 21 Functions . 53 Example Program 2 . 21 Hyperbolic Functions . 53 Example Program 3 . 22 Special Functions . 54 Complex Functions . 54 Identifiers . 25 Predeclared Function Examples . 55 Values and Types . 27 Predeclared Function Simple Types . 27 Domains of Definition . 56 Integer . 27 Real . 28 Constants, Variables, Long Real . 30 Expressions and Values . 57 Complex . 31 Constants . 57 Long Complex . 32 Arithmetic . 57 Logical . 32 Logical, Bits and String . 58 Bits . 32 Reference . 58 String . 33 Variables . 58 Reference . 34 Expressions . 59 Structured Types . 34 Arithmetic Expressions . 59 Array . 34 Logical Expressions . 59 Record . 35 String Expressions . 60 Output of Values . 36 Bits Expressions . 60 Reference Expressions . 60 Simple Variable Declarations . 37 Functions . 60 Integer, Real, Long Real, Conditional Expressions . 60 Complex, Long Complex and If Expression . 60 Logical . 37 Type of Resulting If Bits . 38 Expression . 61 String . 38 Assignment Compatibility . 62 7 MTS 16: ALGOL W in MTS September 1980 Case Expressions . 63 Declarations . .107 Block Expressions . 65 Function Procedures without Formal Parameters .108 Arrays . 67 Function Procedures with Array Declarations . 67 Formal Parameters . .109 Integer, Real, Long Real, Parameter Passing Complex, Long Complex and Conventions . .110 Logical Array Declarations 67 Call by Name . .110 String Array Declarations . 68 Call by Value . .111 Bits Array Declarations . 69 Call by Result . .113 Reference Array Call by Value Result . .114 Declarations . 69 Recursive Procedures . .118 Subscripts . 70 Externally Defined Dynamic Allocation . 71 Procedures . .120 Array Assignments . 71 Sample Programs . 72 Statements . .121 Array Sample Program One . 72 Simple Statements . .121 Array Sample Program Two . 73 Blocks . .121 Assignment Statements . .124 Logicals . 77 Assignment Compatibility .125 Declarations . 77 Procedure Statements . .125 Relations . 77 Goto Statements and Labels 125 Logical Expressions . 80 Predeclared Procedure Precedence . 82 Statements . .128 Logical Assignment Assert Statements . .128 Statements . 82 Empty Statements . .129 Predeclared Functions . 84 Iterative Statements . .130 While Statements . .131 Strings . 85 For Statements . .132 String Declarations . 85 Conditional Statements . .136 String Expressions . 85 If Statements . .136 String Comparisons . 87 Case Statements . .139 String