Marcel van der Veer · Algol 68 Genie
Learning Algol 68 Genie
Learning Algol 68 Genie

Comprehensive Algol 68 programming guide, which includes the Revised Report.

The Algol 68 Genie project

The development of Algol played an important role in establishing computer science as an academic discipline. The Algol 68 Genie project preserves and promotes Algol 68 out of educational as well as scientific-historical interest, by making available a recent checkout compiler-interpreter written from scratch by Marcel van der Veer. Algol 68 Genie is free software distributed under the GNU General Public License.

A detailed description of Algol 68 is in the book Learning Algol 68 Genie which contains an informal introduction to the language, a manual for Algol 68 Genie, and the Revised Report on Algol 68. A hyperlinked HTML version of the Revised Report is available on this page.

About Marcel
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.T. Meertens and
R.G.Fisker
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.

The appendix Specification of partial parametrization proposal is not a part of the Algol 68 Revised Report, and is distributed with Algol 68 Genie with kind permission of the author of this proposal, C.H. Lindsey.
References to this report:

A. van Wijngaarden et al., editors, Revised Report on the Algorithmic Language Algol 68.

» Mathematical Centre Tracts 50
    Mathematisch Centrum Amsterdam
    [1976];
» Acta Informatica 5 1-236 [1976];
» SIGPLAN Notices 12:5 1-70 [1977];
» Springer-Verlag
    ISBN 3-540-07592-5,
    ISBN 0-387-07592-5.

Table of Contents


Preface to the HTML translation

Acknowledgements

0. Introduction

  0.1. Aims and principles of design
    0.1.1. Completeness and clarity of description
    0.1.2. Orthogonal design
    0.1.3. Security
    0.1.4. Efficiency
      0.1.4.1 Static mode checking
      0.1.4.2 Mode-independent parsing
      0.1.4.3 Independent compilation
      0.1.4.4 Loop optimization
      0.1.4.5 Representations
  0.2. Comparison with Algol 60
    0.2.1. Values in Algol 68
    0.2.2. Declarations in Algol 68
    0.2.3. Dynamic storage allocation in Algol 68
    0.2.4. Collateral elaboration in Algol 68
    0.2.5. Standard declarations in Algol 68
    0.2.6. Some particular constructions in Algol 68
  0.3. Comparison with the language defined in 1968
    0.3.1. Casts and routine texts
    0.3.2. Extended ranges
    0.3.3. Conformity clauses
    0.3.4. Modes of multiple values
    0.3.5. Identification of operators
    0.3.6. Representations
    0.3.7. Standard prelude
    0.3.8. Line length in transput
    0.3.9. Internal transput
    0.3.10 Elaboration of formats
    0.3.11 Features removed
  0.4. Changes in the method of description
    0.4.1. Two-level grammar
    0.4.2. Modes
    0.4.3. Extensions
    0.4.4. Semantics
    0.4.5. Translations


PART I - Preliminary definitions

1. Language and metalanguage

  1.1. The method of description
    1.1.1. Introduction
    1.1.2. Pragmatics
    1.1.3. The syntax of the strict language
      1.1.3.1. Protonotions
      1.1.3.2. Production rules and production trees
      1.1.3.3. Metaproduction rules and simple substitution
      1.1.3.4. Hyper-rules and consistent substitution
    1.1.4. The semantics
      1.1.4.1. Hypernotions, designation and envelopment
      1.1.4.2. Paranotions
      1.1.4.3. Undefined
    1.1.5. Translations and variants
  1.2. General metaproduction rules
    1.2.1. Metaproduction rules of modes
    1.2.2. Metaproduction rules associated with phrases and coercion
    1.2.3. Metaproduction rules associated with nests
  1.3. General hyper-rules
    1.3.1. Syntax of general predicates
    1.3.2. The holding of predicates
    1.3.3. Syntax of general constructions

2. The computer and the program

  2.1. Terminology
    2.1.1. Objects
      2.1.1.1. Values, locales, environs and scenes
      2.1.1.2. Modes
      2.1.1.3. Scopes
    2.1.2. Relationships
    2.1.3. Values
      2.1.3.1. Plain values
      2.1.3.2. Names
      2.1.3.3. Structured values
      2.1.3.4. Multiple values
      2.1.3.5. Routines
      2.1.3.6. Acceptability of values
    2.1.4. Actions
      2.1.4.1. Elaboration
      2.1.4.2. Serial and collateral actions
      2.1.4.3. Initiation, completion and termination
    2.1.5. Abbreviations
  2.2. The program


PART II - Fundamental constructions

3. Clauses

  3.1. Closed clauses
  3.2. Serial clauses
  3.3. Collateral and parallel clauses
  3.4. Choice clauses
  3.5. Loop clauses

4. Declarations, declarers and indicators

  4.1. Declarations
  4.2. Mode declarations
  4.3. Priority declarations
  4.4. Identifier declarations
  4.5. Operation declarations
  4.6. Declarers
  4.7. Relationships between modes
  4.8. Indicators and field selectors

5. Units

  5.2. Units associated with names
    5.2.1. Assignations
    5.2.2. Identity relations
    5.2.3. Generators
    5.2.4. Nihils
  5.3. Units associated with stowed values
    5.3.1. Selections
    5.3.2. Slices
  5.4. Units associated with routines
    5.4.1. Routine texts
    5.4.2. Formulas
    5.4.3. Calls
    5.4.4. Jumps
  5.5. Units associated with values of any mode
    5.5.1. Casts
    5.5.2. Skips


PART III - Context dependence

6. Coercion

  6.1. Coercees
  6.2. Dereferencing
  6.3. Deproceduring
  6.4. Uniting
  6.5. Widening
  6.6. Rowing
  6.7. Voiding

7. Modes and nests

  7.1. Independence of properties
  7.2. Identification in nests
  7.3. Equivalence of modes
  7.4. Well-formedness


PART IV - Elaboration-independent constructions

8. Denotations

  8.1. Plain denotations
    8.1.1. Integral denotations
    8.1.2. Real denotations
    8.1.3. Boolean denotations
    8.1.4. Character denotations
    8.1.5. Void denotation
  8.2. Bits denotations
  8.3. String denotations

9. Tokens and symbols

  9.1. Tokens
  9.2. Comments and pragmats
  9.3. Representations
  9.4. The reference language
    9.4.1. Representations of symbols
    9.4.2. Other TAX symbols
      9.4.2.1. Metasyntax
      9.4.2.2. Representation


PART V - Environment and examples

10. Standard environment

  10.1. Program texts
    10.1.2. The environment condition
    10.1.3. The method of description of the standard environment
  10.2. The standard prelude
    10.2.1. Environment enquiries
    10.2.2. Standard modes
    10.2.3. Standard operators and functions
      10.2.3.0. Standard priorities
      10.2.3.1. Rows and associated operations
      10.2.3.2. Operations on boolean operands
      10.2.3.3. Operations on integral operands
      10.2.3.4. Operations on real operands
      10.2.3.5. Operations on arithmetic operands
      10.2.3.6. Operations on character operands
      10.2.3.7. Operations on complex operands
      10.2.3.8. Bits and associated operations
      10.2.3.9. Bytes and associated operations
      10.2.3.10. Strings and associated operations
      10.2.3.11. Operations combined with assignations
      10.2.3.12. Standard mathematical constants and functions
    10.2.4. Synchronization operations
  10.3. Transput declarations
    10.3.1. Books, channels and files
      10.3.1.1. Books and backfiles
      10.3.1.2. Channnels
      10.3.1.3. Files
      10.3.1.4. Opening and closing files
      10.3.1.5. Position enquiries
      10.3.1.6. Layout routines
    10.3.2. Transput values
      10.3.2.1. Conversion routines
      10.3.2.2. Transput modes
      10.3.2.3. Straightening
    10.3.3. Formatless transput
      10.3.3.1. Formatless output
      10.3.3.2. Formatless input
    10.3.4. Format texts
      10.3.4.1. Collections and pictures
      10.3.4.2. Integral patterns
      10.3.4.3. Real patterns
      10.3.4.4. Boolean patterns
      10.3.4.5. Complex patterns
      10.3.4.6. String patterns
      10.3.4.7. Bits patterns
      10.3.4.8. Choice patterns
      10.3.4.9. Format patterns
      10.3.4.10. General patterns
    10.3.5. Formatted transput
      10.3.5.1. Formatted output
      10.3.5.2. Formatted input
    10.3.6. Binary transput
      10.3.6.1. Binary output
      10.3.6.2. Binary input
  10.4. The system prelude and task list
    10.4.1. The system prelude
    10.4.2. The system task list
  10.5. The particular preludes and postludes
    10.5.1. The particular preludes
    10.5.2. The particular postludes

11. Examples

  11.1. Complex square root
  11.2. Innerproduct 1
  11.3. Innerproduct 2
  11.4. Largest element
  11.5. Euler summation
  11.6. The norm of a vector
  11.7. Determinant of a matrix
  11.8. Greatest common divisor
  11.9. Continued fraction
  11.10. Formula manipulation
  11.11. Information retrieval
  11.12. Cooperating sequential processes
  11.13. Towers of Hanoi


12. Glossaries

  12.1. Technical terms
  12.2. Paranotions
  12.3. Predicates
  12.4. Index to the standard prelude
  12.5. Alphabetic listing of metaproduction rules


Appendix. Specification of partial parametrization proposal

  2.1.3.5. Routines
  5.4.1.2. Semantics
  5.4.3. Calls (with partial parametrization)
  5.4.3.2. Semantics

«Table of contents»

{"Languages take such a time, and so do
all the things one wants to know about."
The Lost Road. John Tolkien.}

Preface to the HTML translation

This is a translation {1.1.5} of the Algol 68 Revised Report into HTML, for distribution with Algol 68 Genie, an Open Source Algol 68 compiler-interpreter. Since Algol 68 Genie became available on the Internet in 2001, it has become clear that many people are interested in an Algol 68 implementation, the majority of them being mathematicians or computer scientists. Hence it is expected that there will be an interest in the formal defining document, the Algol 68 Revised Report, which is unfortunately out of print. The language is to this day referred to in teaching material, discussions and publications. It was the first major language to have a complete formal description before an implementation. Because of the rigour and precision of its definition, and the influence it had, a student reading computer science should at an appropriate moment study Algol 68, irrespective of whether the language did or did not spread widely at the time it was presented. For programmers, the world has of course moved on, but the reactions on Algol 68 Genie suggest that many people who have seriously programmed in Algol 68 in the past, only moved to other programming languages because the Algol 68 implementations they were using were phased out.

By making available Algol 68's defining document together with an implementation, those interested in the language can both study it, and use it. A LaTeX translation {1.1.5} based on this HTML translation is in the book Learning Algol 68 Genie, that also has an informal introduction to Algol 68. The original text of the revised report in its original format is available from Dick Grune's legacy Algol 68 data .

ALGOrithmic Language Algol 68 was designed by IFIP Working Group 2.1 (Algorithmic Languages and Calculi) as a general-purpose programming language. This working group has continuing responsibility for Algol 60 and Algol 68. In the early 1960's it started discussing the development of Algol X, a successor to Algol 60. At its 1965 meeting in St. Pierre de Chartreuse, three reports describing more or less complete languages, by Wirth, Seegmüller, and Van Wijngaarden, were amongst the contributions. Van Wijngaarden's paper Orthogonal design and description of a formal language (available from Karl Kleine's collection) featured a new technique for language design and definition. This paper formed the basis for what would develop into Algol 68. Wirth left the project to work on Algol W which influenced his later language Pascal. Algol 68 was defined in a formal document, first published in January 1969, and later published in Acta Informatica and also printed in Sigplan Notices. The revised report was published in 1976.

At the time the formal defining reports on Algol 68 were known to rank among the difficult publications in computer science, and they probably still do. Algol 68's grammar is a two-level W-grammar ('W' for Van Wijngaarden) that can define a potentially infinite grammar in a finite number of rules. It can rigorously define some syntactic restrictions that otherwise have to be formulated in natural language, despite their essentially syntactical content. In a context-sensitive grammar, the left-hand - and right-hand side of a production rule may be surrounded by a context of terminal and nonterminal symbols. This can be clearly recognised in the revised report. The revised report employs hyper-rules and metaproduction rules to construct context-sensitive grammars. For instance, unique declaration of all applied tags in a program (identifiers, operators, and so forth) is ensured via LAYER, PROP and related rules, while well-formed modes are constructed via SAFE and related rules. One way to view the matter is as follows: the mechanism of a two-level grammar is to generate, by substitution of hyper-rules and metaproduction rules to obtain production rules, a tailored context-sensitive grammar needed to parse a particular Algol 68 program. Since every correct particular Algol 68 program has its specific grammar to parse it, a universal Algol 68 grammar, being the set of all grammars for every possible correct Algol 68 program, would be infinite. With this in mind, the revised report is easier to comprehend.

Probably because of the formal character of the revised report, which requires study to comprehend, the misconception got hold that Algol 68 would be a complex language, while in fact it is rather lean. Another factor that hindered Algol 68 from spreading rapidly is that the language was designed for programmers, not for compiler writers, when the field of compiler construction was not as advanced as it is today. Implementation efforts based on formal methods generally failed; Algol 68's context-dependent grammar required some invention to parse. At the time of Algol 68's introduction compilers usually were made available on mainframes by computing centers, which may explain why Algol 68 was popular in locations rather than areas, for instance Amsterdam, Berlin or Cambridge. It appears that Algol 68 was relatively popular in the UK, where the ALGOL68RS and ALGOL68C compilers were developed. An important clue to understanding why Algol 68 did not become a widely used language lies in the fact that industry did not pick it up and that initiatives to commercialise Algol 68 compilers were relatively unsuccessful, for instance the FLACC compiler ran on just twenty-two installations. The market for universal programming languages evidently did not develop as hoped for during the decade in which the language was developed and implemented.

This HTML translation {1.1.5} is my completed and corrected version of an original version by Wilhelm Kloke. Code examples adopt upper-stropping for bold symbols, hence where in the original publication begin is used, in the translation BEGIN will be used. Lay-out may differ in places from that of the original publication. Some character-glyphs {8.1.4.1c, d} that are no longer readily available (for example floor symbol or ceiling symbol) have been omitted from this text. This translation contains comments which are not part of the original text and are contained in parentheses [[ ... a posteriori comments ... ]]. I would like to thank Andy Walker and Charles Lindsey for proofreading this translation, which should be an acceptable representation of the original publication. Should you however have a remark, or find an error, please send a note to algol68g@xs4all.nl. Your feedback will be much appreciated.

Change log

Revision Released Changes
1.5 February 2013 Minor editing
1.4 July 2012 Reformatting and minor editing
1.3 June 2009 Single-page version
1.2 October 2008 Adds various comments
1.1 May 2008 Corrects omission of metaproduction TAB
1.0 March 2008 Adds Revised Report to the documentation

«Table of contents»

Acknowledgements

{Habent sua fata libelli.
De litteris. Terentianus Maurus.}

Working Group 2.1 on ALGOL of the International Federation for Information Processing has discussed the development of "ALGOL X", a successor to Algol 60 [3] since 1963. At its meeting in Princeton in May 1965, WG 2.1 invited written descriptions of the language based on the previous discussions. At the meeting in St Pierre de Chartreuse near Grenoble in October 1965, three reports describing more or less complete languages were amongst the contributions, by Niklaus Wirth [8], Gerhard Seegmueller [6], and Aad van Wijngaarden [9]. In [6] and [8], the descriptional technique of [3] was used, whereas [9] featured a new technique for language design and definition. Other significant contributions available were papers by Tony Hoare [2] and Peter Naur [4, 5].

At subsequent meetings between April 1966 and December 1968, held in Kootwijk near Amsterdam, Warsaw, Zandvoort near Amsterdam, Tirrenia near Pisa and North Berwick near Edinburgh, a number of successive approximations to a final report, commencing with [10] and followed by a series numbered MR 88, MR 92, MR 93, MR 95, MR 99 and MR 100, were submitted by a team working in Amsterdam, consisting first of A. van Wijngaarden and Barry Mailloux, later reinforced by John Peck, and finally by Kees Koster. Versions were used during courses on the language held at various centres, and the experience gained in explaining the language to skilled audiences and the reactions of the students influenced the succeeding versions. The final version, MR 101 [11], was adopted by the Working Group on December 20th 1968 in Munich, and was subsequently approved for publication by the General Assembly of I.F.I.P. Since that time, it has been published in Numerische Mathematik [12], and translations have been made into Russian) [13], into German [14], into French [15], and into Bulgarian [16]. An "Informal Introduction", for the benefit of the uninitiated reader, was also prepared at the request of the Working Group [18].

The original authors acknowledged with pleasure and thanks the wholehearted cooperation, support, interest, criticism and violent objections from members of WG 2.1 and many other people interested in ALGOL. At the risk of embarrassing omissions, special mention should be made of Jan Garwick, Jack Merner, Peter Ingerman and Manfred Paul for [1], the Brussels group consisting of M. Sintzoff, P. Branquart, J. Lewi and P. Wodon for numerous brainstorms, A.J.M. van Gils of Apeldoorn, G. Goos and his group at Munich, also for [7], G.S. Tseytin of Leningrad, and L.G.L.T. Meertens and J.W. de Bakker of Amsterdam. An occasional choice of a, not inherently meaningful, identifier in the sequel may compensate for not mentioning more names in this section.

Since the publication of the Original Report, much discussion has taken place in the Working Group concerning the further development of the language. This has been influenced by the experience of many people who saw disadvantages in the original proposals and suggested revised or extended features. Amongst these must be mentioned especially: I.R. Currie, Susan G. Bond, J.D. Morison and D. Jenkins of Malvern (see in [17]), in whose dialect of Algol 68 many features of this Revision may already be found; P. Branquart, J.P. Cardinael and J. Lewi of Brussels, who exposed many weaknesses (see in [17]); Ursula Hill, H. Woessner and H. Scheidig of Munich, who discovered some unpleasant consequences: the contributors to the Rapport d'Evaluation [19]: and the many people who served on the Working Group subcommittees on Maintenance and Improvements (convened by M. Sintzoff) and on Transput (convened by C.H. Lindsey). During the later stages of the revision, much helpful advice was given by H. Boom of Edmonton, W. Freeman of York, W.J. Hansen of Vancouver, Mary Zosel of Livermore, N. Yoneda of Tokyo, M. Rain of Trondheim, L. Ammeraal, D. Grune, H. van Vliet and R. van Vliet of Amsterdam, G. van der Mey of Delft, and A.A. Baehrs and A.F. Rar of Novosibirsk. The editors of this revision also wish to acknowledge that the wholehearted cooperation, support, interest, criticism and violent objections on the part of the members of WG 2.1 have continued unabated during this time.

[1] J.V. Garwick, J.M. Merner, P.Z. Ingerman and M. Paul, Report of the ALGOL-X - I-O Subcommittee, WG 2.1 Working Paper, July 1966.
[2] C.A.R. Hoare, Record Handling, WG 2.1 Working Paper, October 1965; also AB.21.3.6. November 1965.
[3] P. Naur (Editor), Revised Report on the Algorithmic Language Algol 60, Regnecentralen, Copenhagen, 1962, and elsewhere.
[4] P. Naur, Proposals for a new language, AB.18.3.9, October 1964.
[5] P. Naur, Proposals for introduction on aims, WG 2.1 Working Paper, October 1965.
[6] G. Seegmueller, A proposal four a basis for a Report on a Successor to Algol 60. Bavarian Acad. Sci., Munich, October 1965.
[7] G. Goos, H. Scheidig, G. Seegmueller and H. Walther, Another proposal for ALGOL 67. Bavarian Acad. Sci., Munich, May 1967.
[8] N. Wirth, A Proposal for a Report on a Successor of Algol 60, Mathematisch Centrum, Amsterdam, MR 75, October 1965.
[9] A. van Wijngaarden, Orthogonal Design and Description of a Formal Language, Mathematisch Centrum, Amsterdam, MR 76, October 1965.
[10] A. van Wijngaarden and B.J. Mailloux, A Draft Proposal for the Algorithmic Language ALGOL X, WG 2.1 Working Paper, October 1966.
[11] A. van Wijngaarden (Editor), B.J. Mailloux, J.E.L. Peck and C.H.A. Koster, Report on the Algorithmic Language Algol 68, Mathematisch Centrum. Amsterdam, MR 101, February 1969.
[12] idem, Numerische Mathematik, Vol. 14, pp. 79-218. 1969.
[13] Soobshchenie ob algoritmicheskom yazyke Algol 68, translation into Russian by A.A. Baehrs, A.P. Ershov, L.L. Zmievskaya and A.F. Rar. Kybernetica, Kiev, Part 6 of 1969 and Part 1 of 1970.
[14] Bericht ueber die Algorithmische Sprache Algol 68, translation into German by I.O. Kerner, Akademie-Verlag, Berlin, 1972.
[15] Définition du Langage Algorithmique Algol 68, translation into French by J. Buffet, P. Arnal, A. Quéré (Eds.), Hermann, Paris, 1972.
[16] Algoritmichniyat yezik Algol 68, translation into Bulgarian by D. Toshkov and St. Buchvarov, Nauka i Yzkustvo, Sofia, 1971.
[17] J.E.L. Peck (Ed.), Algol 68 Implementation (proceedings of the I.F.I.P. working conference held in Munich in 1970), North Holland Publishing Company, 1971.
[18] C.H. Lindsey and S.G. van der Meulen, Informal introduction to Algol 68, North Holland Publishing Company 1971.
[19] J.C. Boussard and J.J. Duby (Eds.), Rapport d'Evaluation Algol 68, Revue d'Informatique et de Recherche Opérationelle, B2, Paris, 1970.


«Table of contents»

0. Introduction

0.1. Aims and principles of design

a) In designing the Algorithmic Language Algol 68, Working Group 2.1 on ALGOL of the International Federation for Information Processing expresses its belief in the value of a common programming language serving many people in many countries.

b) Algol 68 is designed to communicate algorithms, to execute them efficiently on a variety of different computers, and to aid in teaching them to students.

c) This present Revision of the language is made in response to the directive of the parent committee, I.F.I.P. TC 2, to the Working Group to "keep continually under review experience obtained as a consequence of this {original} publication, so that it may institute such corrections and revisions to the Report as become desirable". In deciding to bring forward this Revision at the present time, the Working Group has tried to keep in balance the need to accumulate the maximum amount of experience of the problems which arose in the language originally defined, as opposed to the needs of the many teams at present engaged in implementation, for whom an early and simple resolution of those problems is imperative.

d) Although the language as now revised differs in many ways from that defined originally, no attempt has been made to introduce extensive new features and, it is believed, the revised language is still clearly recognizable as "Algol 68". The Working Group has decided that this present revision should be "the final definition of the language Algol 68", and the hope is expressed that it will be possible for implementations at present in preparation to be brought into line with this standard.

e) The Working Group may, from time to time, define sublanguages and extended capabilities, by means of Addenda to this Report, but these will always be built on the language here defined as a firm foundation. Moreover, variants more in conformity with natural languages other than English may be developed. To coordinate these activities, and to maintain contact with implementers and users, a Subcommittee on Algol 68 Support has been established by the Working Group.

f) The members of the Group, influenced by several years of experience with Algol 60 and other programming languages, have always accepted the following as their aims:

0.1.1 Completeness and clarity of description

The Group wishes to contribute to the solution of the problems of describing a language clearly and completely. The method adopted in this Report is based upon a formalized two-level grammar, with the semantics expressed in natural language, but making use of some carefully and precisely defined terms and concepts. It is recognized, however, that this method may be difficult for the uninitiated reader.

0.1.2 Orthogonal design

The number of independent primitive concepts has been minimized in order that the language be easy to describe, to learn, and to implement. On the other hand, these concepts have been applied "orthogonally" in order to maximize the expressive power of the language while trying to avoid deleterious superfluities.

0.1.3 Security

Algol 68 has been designed in such a way that most syntactical and many other errors can be detected easily before they lead to calamitous results. Furthermore, the opportunities for making such errors are greatly restricted.

0.1.4 Efficiency

Algol 68 allows the programmer to specify programs which can be run efficiently on present-day computers and yet do not require sophisticated and time-consuming optimization features of a compiler; see, e.g., 11.7.

0.1.4.1 Static mode checking

The syntax of Algol 68 is such that no mode checking during run time is necessary, except when the programmer declares a UNITED-variable and then, in a conformity-clause, explicitly demands a check on its mode.

0.1.4.2 Mode-independent parsing

The syntax of Algol 68 is such that the parsing of a program can be performed independently of the modes of its constituents. Moreover, it can be determined in a finite number of steps whether an arbitrary given sequence of symbols is a program.

0.1.4.3 Independent compilation

The syntax of Algol 68 is such that the main-line programs and procedures can be compiled independently of one another without loss of object-program efficiency provided that, during each independent compilation, specification of the mode of all nonlocal quantities is provided: see the remarks after 2.2.2.c.

0.1.4.4 Loop optimization

Iterative processes are formulated in Algol 68 in such a way that straightforward application of well-known optimization techniques yields large gains during run time without excessive increase of compilation time.

0.1.4.5 Representations

Representations of Algol 68 symbols have been chosen so that the language may be implemented on computers with a minimal character set. At the same time implementers may take advantage of a larger character set, if it is available.

0.2 Comparison with Algol 60

a) Algol 68 is a language of wider applicability and power than Algol 60. Although influenced by the lessons learned from Algol 60, Algol 68 has not been designed as an expansion of Algol 60 but rather as a completely new language based on new insight into the essential, fundamental concepts of computing and a new description technique.

b) The result is that the successful features of Algol 60 reappear in Algol 68 but as special cases of more general constructions, along with completely new features. It is, therefore, difficult to isolate differences between the two languages: however, the following sections are intended to give insight into some of the more striking differences.

0.2.1 Values in Algol 68

a) Whereas Algol 60 has values of the types integer, real and Boolean, Algol 68 features an infinity of "modes", i.e., generalizations of the concept "type".

b) Each plain value is either arithmetic, i.e., of 'integral' or 'real' mode and then it is of one of several sizes, or it is of 'boolean' or 'character' or 'void' mode. Machine words, considered as sequences of bits or of bytes, may also be handled.

c) In Algol 60, values can be composed into arrays, whereas in Algol 68, in addition to such "multiple" values, also "structured" values, composed of values of possibly different modes, are defined and manipulated. An example of a multiple value is the character array, which corresponds approximately to the Algol 60 string; examples of structured values are complex numbers and symbolic formulae.

d) In Algol 68 the concept of a "name" is introduced, i.e., a value which is said to "refer to" another value; such a name-value pair corresponds to the Algol 60 variable. However, a name may take the value position in a name-value pair, and thus chains of indirect addresses can be built up.

e) The Algol 60 concept of procedure body is generalized in Algol 68 to the concept of "routine", which includes also the formal parameters, and which is itself a value and therefore can be manipulated like any other value.

f) In contrast with plain values, the significance of a name or routine is, in general, dependent upon the existence of the storage cells referred to or accessed. Therefore, the use of names and routines is subject to some restrictions related to their "scope". However, the syntax of Algol 68 is such that in many cases the check on scope can be made at compile time, including all cases where no use is made of features whose expressive power transcends that of Algol 60.

0.2.2 Declarations in Algol 68

a) Whereas Algol 60 has type declarations, array declarations, switch declarations and procedure declarations, Algol 68 features the identity-declaration whose expressive power includes all of these, and more. The identity-declaration, although theoretically sufficient in itself, is augmented by the variable-declaration for the convenience of the user.

b) Moreover, in Algol 68, a mode-declaration permits the construction of a new mode from already existing ones. In particular, the modes of multiple values and of structured values may be defined in this way; in addition, a union of modes may be defined, allowing each value referred to by a given name to be of any one of the uniting modes.

c) Finally, in Algol 68, a priority-declaration and an operation-declaration permit the introduction of new operators, the definition of their operation and the extension of the class of operands of, and the revision of the meaning of, already established operators.

0.2.3 Dynamic storage allocation in Algol 68

Whereas Algol 60 (apart from "own dynamic arrays") implies a "stack"-oriented storage-allocation regime, sufficient to cope with objects having nested lifetimes (an object created before another object being guaranteed not to become inaccessible before that second one), Algol 68 provides, in addition, the ability to create and manipulate objects whose lifetimes are not so restricted. This ability implies the use of an additional area of storage, the "heap", in which garbage-collection techniques must be used.

0.2.4 Collateral elaboration in Algol 68

Whereas, in Algol 60, statements are "executed consecutively", in Algol 68, phrases are "elaborated serially" or "collaterally". This latter facility is conducive to more efficient object programs under many circumstances, since it allows discretion to the implementer to choose, in many cases, the order of elaboration of certain constructs or even, in some cases, whether they are to be elaborated at all. Thus the user who expects his "side effects" to take place in any well determined manner will receive no support from this Report. Facilities for parallel programming, though restricted to the essentials in view of the none-too-advanced state of the art, have been introduced.

0.2.5 Standard declarations in Algol 68

The Algol 60 standard functions are all included in Algol 68 along with many other standard declarations. Amongst these are "environment enquiries", which make it possible to determine certain properties of an implementation, and "transput" declarations, which make it possible, at run time, to obtain data from and to deliver results to external media.

0.2.6 Some particular constructions in Algol 68

a) The Algol 60 concepts of block, compound statement and parenthesized expression are unified in Algol 68 into the serial-clause. A serial-clause may be an expression and yield a value. Similarly, the Algol 68 assignation, which is a generalization of the Algol 60 assignment statement, may be an expression and, as such, also yield a value.

b) The Algol 60 concept of subscripting is generalized to the Algol 68 concept of "indexing", which allows the selection not only of a single element of an array but also of subarrays with the same or any smaller dimensionality and with possibly altered bounds.

c) Algol 68 provides row-displays and structure-displays, which serve to compose the multiple and structured values mentioned in 0.2.1.c from other, simpler, values.

d) The Algol 60 for statement is modified into a more concise and efficient loop-clause.

e) The Algol 60 conditional expression and conditional statement, unified into a conditional-clause, are improved by requiring them to end with a closing symbol whereby the two alternative clauses admit the same syntactic possibilities. Moreover, the conditional-clause is generalized into a case-clause, which allows the efficient selection from an arbitrary number of clauses depending on the value of an integral-expression, and a conformity-clause, which allows a selection depending upon the actual mode of a value.

f) Some less successful Algol 60 concepts, such as own quantities and integer labels, have not been included in Algol 68, and some concepts, like designational expressions and switches, do not appear as such in Algol 68 but their expressive power is included in other, more general, constructions.

0.3 Comparison with the language defined in 1968

The more significant changes to the language are indicated in the sections which follow. The revised language will be described in a new edition of the "Informal Introduction to Algol 68" by C.H. Lindsey and S.G. van der Meulen, which accompanied the original Report.

0.3.1 Casts and routine texts

Routines without parameters used to be constructed out of a cast in which the cast-of-symbol (:) appeared. This construct is now one of the forms of the new routine-text, which provides for procedures both with and without parameters. A new form of the cast has been provided which may be used in contexts previously not possible. Moreover, both void-casts and procedure-PARAMETY-yielding-void-routine-texts must now contain an explicit void-symbol.

0.3.2 Extended ranges

The new range which is established by the enquiry-clause of a choice-clause (which encompasses the old conditional- and case-clauses) or of a while-part now extends into the controlled serial-clause or do-part.

0.3.3 Conformity clauses

The conformity-relation and the case-conformity which was obtained by extension from it are now replaced by a new conformity-clause, which is a further example of the choice-clause mentioned above.

0.3.4 Modes of multiple values

A new class of modes is introduced, for multiple values whose elements are themselves multiple values. Thus one may now write the declarer [] string.

Moreover, multiple values no longer have "states" to distinguish their flexibility. Instead, flexibility is now a property of those names which refer to multiple values whose size may change, such names having distinctive modes of the form 'reference to flexible ROWS of MODE'.

0.3.5 Identification of operators

Not only may two operators, related to each other by the modes of their operands, not be declared in the same range, as before, but now, if two such operators be declared in different reaches, any attempt to identify from the inner reach the one in the outer reach will fail. This gives some benefit to the implementer and removes a source of possible confusion to the user.

0.3.6 Representations

The manner in which symbols for newly defined mode-indications and operators are to be represented is now more closely defined. Thus it is clear that the implementer is to provide a special alphabet of bold-faced, or "stropped", marks from which symbols such as person may be made, and it is also clear that operators such as >> are to be allowed.

0.3.7 Standard prelude

In order to ease the problems of implementers who might wish to provide variants of the language suitable for environments where English is not spoken, there are no longer any field-selectors known to the user in the standard-prelude, with the exception of re and im of the mode COMPL. The identifiers and other indicators declared in the standard-prelude could, of course, easily be defined again in some library-prelude, but this would not have been possible in the case of field-selectors.

0.3.8 Line length in transput

The lines (and the pages also) of the "book" used during transput may now, at the discretion of the implementer, be of varying lengths. This models more closely the actual behaviour of most operating systems and of devices such as teleprinters and paper-tape readers.

0.3.9 Internal transput

The transput routines, in addition to sending data to or from external media, may now be associated with row-of-character-variables declared by the user.

0.3.10 Elaboration of formats

The dynamic replicators contained in format-texts are now elaborated as and when they are encountered during the formatted transput process. This should give an effect more natural to the user, and is easier to implement.

0.3.11 Features removed

Certain features, such as proceduring, gommas and formal bounds, have not been included in the revision.

0.4 Changes in the method of description

In response to the directive from the Working Group "to make its study easier for the uninitiated reader", the Editors of this revision have rewritten the original Report almost entirely, using the same basic descriptional technique, but applying it in new ways. It is their hope that less "initiation" will now be necessary.

The more significant changes in the descriptional technique are indicated below.

0.4.1 Two-level grammar

a) While the syntax is still described by a two-level grammar of the type now widely known by the name "Van Wijngaarden", new techniques for using such grammars have been applied. In particular, the entire identification process is now described in the syntax using the metanotion "NEST", whose terminal metaproductions are capable of describing, and of passing on to the descendent constructs, all the declared information which is available at any particular node of the production tree.

b) In addition, extensive use is made of "predicates". These are notions which are deliberately made to yield blind alleys when certain conditions are not met, and which yield empty terminal productions otherwise. They have enabled the number of syntax rules to be reduced in many cases, while at the same time making the grammar easier to follow by reducing the number of places where a continuation of a given rule might be found.

It has thus been possible to remove all the "context conditions" contained in the original Report.

0.4.2 Modes

a) In the original Report, modes were protonotions of possibly infinite length. It was assumed that, knowing how an infinite mode had been obtained, it was decidable whether or not it was the same as some other infinite mode. However, counterexamples have come to light where this was not so. Therefore, it has been decided to remove all infinities from the process of producing a finite program and, indeed, this can now be done in a finite number of moves.

b) A mode, essentially, has to represent a potentially infinite tree. To describe it as a protonotion of finite length requires the use of markers {'MU definition's} and pointers back to those markers {'MU application's} within the protonotion. However, a given infinite tree can be "spelled" in many ways by this method, and therefore a mode becomes an equivalence class comprised of all those equivalent spellings of that tree. The equivalence is defined in the syntax using the predicates mentioned earlier.

0.4.3 Extensions

The need for many of the extensions given in the original Report had been removed by language changes. Some of the remainder had been a considerable source of confusion and surprises. The opportunity has therefore been taken to remove the extension as a descriptional mechanism, all the former extensions now being specified directly in the syntax.

0.4.4 Semantics

a) In order to remove some rather repetitious phrases from the semantics, certain technical terms have been revised and others introduced. The grammar, instead of producing a terminal production directly, now does so by way of a production tree. The semantics is explained in terms of production trees. Paranotions, which designate constructs, may now contain metanotions and "hypernotions" have been introduced in order to designate protonotions.

b) A model of the hypothetical computer much more closely related to a real one has been introduced. The elaboration of each construct is now presumed to take place in an "environ" and, when a new range is entered (and, in particular, when a routine is called), a new "locale" is added to the environ. The locale corresponds to the new range and, if recursive procedure calls arise, then there exist many locales corresponding to one same routine. This supersedes the method of "textual substitution" used before, and one consequence of this is that the concept of "protection" is no longer required.

c) The concept of an "instance" of a value is no longer used. This simplifies certain portions of the semantics where, formerly, a "new instance" had to be taken, the effects of which were not always clear to see.

0.4.5 Translations

The original Report has been translated into various natural languages. The translators were not always able to adhere strictly to the descriptional method, and so the opportunity has been taken to define more clearly and more liberally certain descriptional features which caused difficulties (see 1.1.5 ).

{True wisdom knows it must comprise
some nonsense as a compromise,
lest fools should fail to find it wise.
Grooks, Piet Hein.}

«Table of contents»

PART I - Preliminary definitions

1. Language and metalanguage

1.1. The method of description

1.1.1. Introduction

a) Algol 68 is a language in which algorithms may be formulated for computers, i.e., for automata or for human beings. It is defined by this Report in four stages, the "syntax" {b}, the "semantics" {c}, the "representations" {d} and the "standard environment" {e}.

b) The syntax is a mechanism whereby all the constructs of the language may be produced. This mechanism proceeds as follows:

  1. A set of "hyper-rules" and a set of "metaproduction rules" are given {1.1.3.4, 1.1.3.3}, from which "production rules" may be derived:
  2. A "construct in the strict language" is a "production tree" {1.1.3.2.f} which may be produced by the application of a subset of those production rules; this production tree contains static information {i.e., information known at "compile time"} concerning that construct: it is composed of a hierarchy of descendent production trees, terminating at the lowest level in the "symbols"; with each production tree is associated a "nest" of properties, declared in the levels above, which is passed on to the nests of its descendents;
  3. A "program in the strict language" is a production tree for the notion 'program' {2.2.1.a}. It must also satisfy the "environment condition" {10.1.2}.

c) The semantics ascribes a "meaning" {2.1.4.1.a} to each construct {i.e., to each production tree} by defining the effect (which may, however, be "undefined") of its "elaboration" {2.1.4.1}. This proceeds as follows:

  1. A dynamic {i.e., run-time} tree of active "actions" is set up {2.1.4}; typically, an action is the elaboration of some production tree T in an "environ" consistent with the nest of T, and it may bring about the elaboration of descendents of T in suitable newly created descendent environs;
  2. The meaning of a program in the strict language is the effect of its elaboration in the empty "primal environ".

d) A program in the strict language must be represented in some "representation language" {9.3.a} chosen by the implementer. In most cases this will be the official "reference language".

  1. A program in a representation language is obtained by replacing the symbols of a program in the strict language by certain typographical marks {9.3}.
  2. Even the reference language allows considerable discretion to the implementer {9.4.a, b, c}. A restricted form of the reference language in which such freedom has not been exercised may be termed the "canonical form" of the language, and it is expected that this form will be used in algorithms intended for publication.
  3. The meaning of a program in a representation language is the same as that of the program {in the strict language} from which it was obtained.

e) An algorithm is expressed by means of a particular-program, which is considered to be embedded, together with the standard environment, in a program-text {10.1.1.a}. The meaning of a particular-program {in the strict or a representation language} is the meaning of the program "akin" to that program-text {10.1.2.a}.

1.1.2. Pragmatics

{Merely corroborative detail, intended to
give artistic verisimilitude to an otherwise
bald and unconvincing narrative.
Mikado, W.S. Gilbert.}

Scattered throughout this Report are "pragmatic" remarks included between the braces " {" and "}". These are not part of the definition of the language but serve to help the reader to understand the intentions and implications of the definitions and to find corresponding sections or rules.

{Some of the pragmatic remarks contain examples written in the reference language. In these examples, applied-indicators occur out of context from their defining-indicators. Unless otherwise specified, these occurrences identify those in the standard- or particular-preludes and the particular-postlude {10.2, 10.3, 10.5} (e.g., see 10.2.3.12.a for pi, 10.5.1.b for random and 10.5.2.a for stop), or those in:

INT i, j, k, m, n; REAL a, b, x, y; BOOL p, q, overflow; CHAR c; FORMAT f;
   BYTES r; STRING s; BITS t; COMPL w, z; REF REAL xx, yy; UNION (INT, REAL) uir;
   PROC VOID task1, task2;
[1 : n] REAL x1, y1; FLEX [1 : n] REAL a1; [1 : m, 1 : n] REAL x2;
   [1 : n, 1 : n] REAL y2; [1 : n] INT i1; [1 : m, 1 : n ] INT i2;
   [1 : n] COMPL z1;
PROC x or y = REF REAL: IF random < .5 THEN x ELSE y FI;
PROC ncos = (INT i)REAL: cos (2 * pi * i / n);
PROC nsin = (INT i)REAL: sin (2 * pi * i / n);
PROC finish = VOID: GO TO stop;
MODE BOOK = STRUCT (STRING text, REF BOOK next);
BOOK draft;
princeton: grenoble: st pierre de chartreuse: kootwijk: warsaw:
   zandvoort: amsterdam: tirrenia: north berwick: munich:
   finish.
}

1.1.3. The syntax of the strict language

1.1.3.1. Protonotions

a) In the definition of the syntax of the strict language, a formal grammar is used in which certain syntactic marks appear. These may be classified as follows:

  1. "small syntactic marks", written, in this Report, as
    "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", " (", ")";
  2. "large syntactic marks", written, in this Report, as
    "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9";
  3. "other syntactic marks", written, in this Report, as
    "." ("point"), "," ("comma"), ":" ("colon"), ";" ("semicolon"), "" ("apostrophe"), "-" ("hyphen") and "*" ("asterisk").
{Note that these marks are in another type font than that of the marks in this sentence.}

b) A "protonotion" is a possibly empty sequence of small syntactic marks.

c) A "notion" is a {nonempty} protonotion for which a production rule can be derived {1.1.3.2.a, 1.1.3.4.d}.

d) A "metanotion" is a {nonempty} sequence of large syntactic marks for which a metaproduction rule is given or created {1.1.3.3.a}.

e) A "hypernotion" is a possibly empty sequence each of whose elements either is a small syntactic mark or is a metanotion.

{Thus the class of protonotions {b} is a subclass of the class of hypernotions. Hypernotions are used in metaproduction rules {1.1.3.3}, in hyper-rules {1.1.3.4}, as paranotions {1.1.4.2} and, in their own right, to "designate" certain classes of protonotions {1.1.4.1}.}

{A "paranotion" is a hypernotion to which certain special conventions and interpretations apply, as detailed in 1.1.4.2 .}

f) A "symbol" is a protonotion ending with 'symbol'. {Note that the paranotion symbol {9.1.1.h} designates a particular occurrence of such a protonotion.}

{Examples:
b) 'variable point'
c) 'variable point numeral' {8.1.2.1.b}
d) "INTREAL" {1.2.1.C}
e) 'reference to INTREAL'
f) 'letter a symbol'. }

Note that the protonotion 'twas brillig and the slithy toves' is neither a symbol nor a notion, in that it does not end with 'symbol' and no production rule can be derived for it. Likewise, "LEWIS" and "CAROLL" are not metanotions in that no metaproduction rules are given for them.

g) In order to distinguish the various usages in the text of this Report of the terms defined above, the following conventions are adopted:

  1. No distinguishing marks {quotes, apostrophes or hyphens} are used in production rules, metaproduction rules or hyper-rules;
  2. Metanotions, and hypernotions which stand for themselves {i.e., which do not designate protonotions}, are enclosed in quotes;
  3. Paranotions are not enclosed in anything {but, as an aid to the reader, are provided with hyphens where, otherwise, they would have been provided with blanks};
  4. All other hypernotions {including protonotions} not covered above are enclosed in apostrophes {in order to indicate that they designate some protonotion, as defined in 1.1.4.1.a};
  5. Typographical display features, such as blank space, hyphen, and change to a new line or new page, are of no significance (but see also 9.4.d ).

{Examples: (i) LEAP :: local ; heap ; primal. is a metaproduction rule ; (ii) "INTREAL" is a metanotion and designates nothing but itself; (iii) reference-to-INTREAL-identifier, which is not enclosed in apostrophes but is provided with hyphens, is a paranotion designating a construct {1.1.4.2.a}; (iv) 'variable point' is both a hypernotion and a protonotion; regarded as a hypernotion, it designates itself regarded as a protonotion; (v) 'reference to real' means the same as 'referencetoreal'.}

1.1.3.2. Production rules and production trees

a) The {derived} "production rules" {b} of the language are those production rules which can be derived from the "hyper-rules" {1.1.3.4}, together with those specified informally in 8.1.4.1.d and 9.2.1.d.

b) A "production rule" consists of the following items, in order:

an optional asterisk ; a nonempty protonotion N ; a colon ; a nonempty sequence of "alternatives" separated by semicolons ; a point.
It is said to be a production rule "for" {the notion {1.1.3.1.c}} N.

{The optional asterisk, if present, signifies that the notion is not used in other production rules, but is provided to facilitate discussion in the semantics. It also signifies that that notion may be used as an "abstraction" {1.1.4.2.b} of one of its alternatives.}

c) An "alternative" is a nonempty sequence of "members" separated by commas.

d) A "member" is either

  1. a notion {and may then be said to be productive, or nonterminal},
  2. a symbol {which is terminal},
  3. empty, or
  4. some other protonotion {for which no production rule can be derived}, which is then said to be a "blind alley".
{For example, the member 'reference to real denotation' (derived from the hyper-rule 8.0.1.a ) is a blind alley.}

{Examples: b) exponent part : times ten to the power choice, power of ten. {8.1.2.1.g}• times ten to the power choice : times ten to the power symbol ; letter e symbol. {8.1.2.1.h} c) times ten to the power choice, power of ten • times ten to the power symbol • letter e symbol d) times ten to the power choice • power of ten • times ten to the power symbol • letter e symbol}

e) A "construct in the strict language" is any "production tree" {f} that may be "produced" from a production rule of the language.

f) A "production tree" T for a notion N, which is termed the "original" of T, is "produced" as follows:

  • let P be some {derived} production rule for N;
  • a copy is taken of N;
  • a sequence of production trees, the "direct descendents" of T, one produced for each nonempty member of some alternative A of P, is attached to the copy; the order of the sequence is the order of those members within A;
  • the copy of the original, together with the attached direct descendents, comprise the production tree T.
A "production tree" for a symbol consists of a copy of that symbol {i.e., it consists of a symbol}.

The "terminal production" of a production tree T is a sequence consisting of the terminal productions of the direct descendents of T, taken in order.

The "terminal production" of a production tree consisting only of a symbol is that symbol.

Example:

    
     'exponent part'
      |
      ---------------------
      |                   |
      |                  'power of ten'
      |                   |
      |                   --------------------
      |                   |                  |
      |                   |                 'fixed point numeral'
      |                   |                  |
      |                   |                 'digit cypher sequence'
      |                   |                  |
      |                   |                  ---------------------
      |                   |                  |                   |
      |                   |                  |                  'digit cypher sequence'
      |                   |                  |                   |
      |                  'plusminus option' 'digit cypher'      'digit cypher'
      |                   |                  |                   |
     'times ten to the    |                  |                   |
      power choice'      'plusminus'        'digit zero'        'digit two'
      |                   |                  |                   |
     'letter e symbol'   'plus symbol'      'digit zero symbol' 'digit two symbol'
    
    

{The terminal production of this tree is the sequence of symbols at the bottom of the tree. In the reference language, its representation would be e+02.}

A "terminal production" of a notion is the terminal production of some production tree for that notion {thus there are many other terminal productions of 'exponent part' besides the one shown}.

{The syntax of the strict language has been chosen in such a way that a given sequence of symbols which is a terminal production of some notion is so by virtue of a unique production tree, or by a set of production trees which differ only in such a way that the result of their elaboration is the same (e.g., production trees derived from rules 3.2.1.e (balancing), 1.3.1.d,e (predicates) and 6.7.1.a,b (choice of spelling of the mode of a coercend to be voided); see also 2.2.2.a ).

Therefore, in practice, terminal productions (or representations thereof) are used, in this Report and elsewhere, in place of production trees. Nevertheless, it is really the production trees in terms of which the elaboration of programs is defined by the semantics of this Report, which is concerned with explaining the meaning of those constructs whose originals are the notion 'program'.}

g) A production tree P is a "descendent" of a production tree Q if it is a direct descendent {f} either of Q or of a descendent of Q. Q is said to "contain" its descendents and those descendents are said to be "smaller" than Q. {For example, the production tree

    
     'plusminus option'
      |
     'plusminus'
      |
     'plus symbol'
    
    

occurs as a descendent in (and is contained within and is smaller than) the production tree for 'exponent part' given above.}

h) A "visible" ("invisible") production tree is one whose terminal production is not (is) empty.

i) A descendent {g} U of a production tree T is "before" ("after") a descendent V of T if the terminal production {f} of U is before (after) that of V in the terminal production of T. The {partial} ordering of the descendents of T thus defined is termed the "textual order". {In the example production tree for 'exponent part' {f}, the production tree whose original is 'plusminus' is before that whose original is 'digit two'.}

j) A descendent A of a production tree "follows" ("precedes") another descendent B in some textual order if A is after (before) B in that textual order, and there exists no visible {h} descendent C which comes between A and B. {Thus "immediately" following (preceding) is implied.}

k) A production tree A is "akin" to a production tree B if the terminal production {f} of A is identical to the terminal production of B.

1.1.3.3. Metaproduction rules and simple substitution

{The metaproduction rules of the language form a set of context-free grammars defining a "metalanguage".}

a) The "metaproduction rules" {b} of the language are those given in the sections of this Report whose heading begins with "Syntax", " Metasyntax" or "Metaproduction rules", together with those obtained as follows:

  • for each given metaproduction rule, whose metanotion is M say, additional rules are created each of which consists of a copy of M followed by one of the large syntactic marks "0", "1", "2", "3", "4", "5", "6", "7", "8" or "9", followed by two colons, another copy of that M and a point.
{Thus, the metaproduction rule "MODE1 :: MODE." is to be added.}

b) A "metaproduction rule" consists of the following items, in order:

    an optional asterisk;
    a nonempty sequence M of large syntactic marks;
    two colons;
    a nonempty sequence of hypernotions {1.1.3.1.e} separated by semicolons;
    a point.
It is said to be a metaproduction rule "for" {the metanotion {1.1.3.1.d}} M.

{The asterisk, if present, signifies that the metanotion is not used in other metaproduction rules or in hyper-rules, but is provided to facilitate discussion in the semantics.}

{Examples:

INTREAL :: SIZETY integral ; SIZETY real. (1.2.1.C)•
SIZETY :: long LONGSETY ; short SHORTSETY ; EMPTY. (1.2.1.D) }

c) A "terminal metaproduction" of a metanotion M is any protonotion which is a "simple substitute" {d} for one of the hypernotions {on the right hand side} of the metaproduction rule for M.

d) A protonotion P is a "simple substitute" for a hypernotion H if a copy of H can be transformed into a copy of P by replacing each metanotion M in the copy by some terminal metaproduction of M.

{Thus two possible terminal metaproductions {c} of "INTREAL" are 'integral' and 'long long real'. This is because the hypernotions 'SIZETY integral' and 'SIZETY real' (the hypernotions of the metaproduction rule for "INTREAL") may, upon simple substitution {d}, give rise to 'integral' and 'long long real', which, in turn, is because '' (the empty protonotion) and 'long long' are terminal metaproductions of "SIZETY".}

{The metanotions used in this Report have been so chosen that no concatenation of one or more of them gives the same sequence of large syntactic marks as any other such concatenation. Thus a source of possible ambiguity has been avoided.

Although the recursive nature of some of the metaproduction rules makes it possible to produce terminal metaproductions of arbitrary length, the length of the terminal metaproductions necessarily involved in the production of any given program is finite.}

1.1.3.4. Hyper-rules and consistent substitution

a) The hyper-rules {b} of the language are those given in the sections of this Report whose heading begins with "Syntax".

b) A "hyper-rule" consists of the following items, in order:

    an optional asterisk ;
    a nonempty hypernotion H ;
    a colon ;
    a nonempty sequence of "hyperalternatives" separated by semicolons ;
    a point.
It is said to be a hyper-rule "for" {the hypernotion {1.1.3.1.e}} H.

c) A "hyperalternative" is a nonempty sequence of hypernotions separated by commas.

{Examples:
b) NOTION sequence : NOTION ; NOTION, NOTION sequence. {1.3.3.b}
c) NOTION, NOTION sequence }

d) A production rule PR {1.1.3.2.b} is derived from a hyper-rule HR if a copy of HR can be transformed into a copy of PR by replacing the set of all the hypernotions in the copy by a "consistent substitute" {e} for that set.

e) A set of {one or more} protonotions PP is a "consistent substitute" for a corresponding set of hypernotions HH if a copy of HH can be transformed into a copy of PP by means of the following step:

Step :
    If the copy contains one or more metanotions then, for some terminal metaproduction T of one such metanotion M, each occurrence of M in the copy is replaced by a copy of T and the Step is taken again.
{See 1.1.4.1.a for another application of consistent substitution.}

{Applying this derivation process to the hyper-rule given above {c} may give rise to

    digit cypher sequence : digit cypher ; digit cypher, digit cypher sequence.
which is therefore a production rule of the language. Note that
    digit cypher sequence : digit cypher ; digit cypher, letter b sequence.
is not a production rule of the language, since the replacement of the metanotion "NOTION" by one of its terminal metaproductions must be consistent throughout.}

{Since some metanotions have an infinite number of terminal metaproductions, the number of production rules which may be derived is infinite. The language is, however, so designed that, for the production of any program of finite length, only a finite number of those production rules is needed.}

{f) The rules under Syntax are provided with "cross-references" to be interpreted as follows.

Each hypernotion H of a hyperalternative of a hyper-rule A is followed by a reference to those hyper-rules B whose derived production rules are for notions which could be substituted for that H. Likewise, the hypernotions of each hyper-rule B are followed by a reference back to A. Alternatively, if H is to be replaced by a symbol, then it is followed by a reference to its representation in section 9.4.1 . Moreover, in some cases, it is more convenient to give a cross-reference to one metaproduction rule rather than to many hyper-rules, and in these cases the missing cross-references will be found in the metaproduction rule.

Such a reference is, in principle, the section number followed by a letter indicating the line where the rule or representation appears, with the following conventions:

  1. the references whose section number is that of the section in which they appear are given first and their section number is omitted; e.g., "8.2.1.a" appears as "a" in section "8.2.1 ";
  2. all points and a final 1 are omitted, and 10 appears as A; e.g., "8.2.1.a" appears as "82a" elsewhere and "10.3.4.1.1.i" appears as "A341i";
  3. a section number which is the same as that of the preceding reference is omitted; e.g., "82a,82b,82c" appears as "82a,b,c";
  4. the presence of a blind alley derived from that hypernotion is indicated by "-"; e.g., in 8.0.1.a after "MOID denotation", since "MOID" may be replaced by, for example, 'reference to real', but 'reference to real denotation' is not a notion.}

1.1.4. The semantics

The "meaning" of programs {2.2.1.a} in the strict language is defined in the semantics by means of sentences {in somewhat formalized natural language} which specify the "actions" to be carried out during the "elaboration" {2.1.4.1} of those programs. The "meaning" of a program in a representation language is the same as the meaning of the program in the strict language which it represents {9.3}.

{The semantics makes extensive use of hypernotions and paranotions in order to "designate", respectively, protonotions and constructs. The word "designate" should be understood in the sense that the word "flamingo" may "designate" any animal of the family Phoenicopteridae.}

1.1.4.1. Hypernotions, designation and envelopment

{Hypernotions, when enclosed between apostrophes, are used to "designate" protonotions belonging to certain classes; e.g., 'LEAP' designates any of the protonotions 'local', 'primal' and 'heap'.}

a) Hypernotions standing in the text of this Report, except those in hyper-rules {1.1.3.4.b} or metaproduction rules {1.1.3.3.b}, "designate" any protonotions which may be consistently substituted {1.1.3.4.e} for them, the consistent substitution being applied over all the hypernotions contained in each complete sub-section of the text (a sub-section being one of the lettered sub-divisions, if any, or else the whole, of a numbered section).

{Thus 'QUALITY TAX' is a hypernotion designating protonotions such as 'integral letter i', 'real letter x', etc. If, in some particular discussion, it in fact designates 'integral letter i', then all occurrences of "QUALITY" in that subsection must, over the span of that discussion, designate 'integral' and all occurrences of "TAX" must designate 'letter i'. It may then be deduced from subsection 4.8.2.a that in order, for example, to "ascribe to an integral-defining-indicator-with-letter-i", it is 'integral letter i' that must be "made to access V inside the locale".}

Occasionally, where the context clearly so demands, consistent substitution may be applied over less than a section. {For example, in the introduction to section 2.1.1.2, there are several occurrences of "'MOID'", of which two are stated to designate specific (and different) protonotions spelled out in full, and of which others occur in the plural form "'MOID's", which is clearly intended to designate a set of different members of the class of terminal metaproductions of "MOID".}

b) If a protonotion (a hypernotion) P consists of the concatenation of the protonotions (hypernotions) A, B and C, where A and C are possibly empty, then P "contains" B at the position {in P} determined by the length of A. {Thus, 'abcdefcdgh' contains 'cd' at its third and seventh positions.}

c) A protonotion P1 "envelops" a protonotion P2 as specifically designated by a hypernotion H2 if P2, or some equivalent {2.1.1.2.a} of it, is contained {b} at some position within P1 but not, at that position, within any different {intermediate} protonotion P3 also contained in P1 such that H2 could also designate P3.
{Thus the 'MODE' enveloped by 'reference to real closed clause' is 'reference to real' rather than 'real'; moreover, the mode {2.1.1.2.b} specified by STRUCT (REAL a, STRUCT (BOOL b, CHAR c) d) envelops 'FIELD' just twice.}

1.1.4.2. Paranotions

{In order to facilitate discussion, in this Report, of constructs with specified originals, the concept of a "paranotion" is introduced. A paranotion is a noun that designates constructs {1.1.3.2.e}; its meaning is not necessarily that found in a dictionary but can be construed from the rules which follow.}

a) A "paranotion" P is a hypernotion {not between apostrophes} which is used, in the text of this Report, to "designate" any construct whose original O satisfies the following:

  • P, regarded as a hypernotion {i.e., as if it had been enclosed in apostrophes}, designates {1.1.4.1.a} an "abstraction" {b} of O.
{For example, the paranotion "fixed-point-numeral" could designate the construct represented by 02, since, had it been in apostrophes, it would have designated an abstraction of the notion 'fixed point numeral', which is the original of that construct. However, that same representation could also be described as a digit-cypher-sequence, and as such it would be a direct descendent of that fixed-point-numeral.}

{As an aid to the reader in distinguishing them from other hypernotions, paranotions are not enclosed between apostrophes and are provided with hyphens where, otherwise, they would have been provided with blanks.}

The meaning of a paranotion to which the small syntactic mark "s" has been appended is the same as if the letter "s" {which is in the same type font as the marks in this sentence} had been appended instead. {Thus the fixed-point-numeral 02 may be said to contain two digit-cyphers, rather than two digit-cyphers.} Moreover, the "s" may be inserted elsewhere than at the end if no ambiguity arises {e.g., "sources-for-MODINE" means the same as "source-for-MODINEs"}.

An initial small syntactic mark of a paranotion is often replaced by the corresponding large syntactic mark (in order to improve readability, as at the start of a sentence) without change of meaning {; e.g., "Identifier" means the same as "identifier"}.

b) A protonotion P2 is an "abstraction" of a protonotion P1 if

  1. P2 is an abstraction of a notion whose production rule begins with an asterisk and of which P1 is an alternative
      {e.g., 'trimscript' {5.3.2.1.h} is an abstraction of any of the notions designated by 'NEST trimmer', 'NEST subscript' and 'NEST revised lower bound option'}, or
  2. P1 envelops a protonotion P3 which is designated by one of the "elidible hypernotions" listed in section c below, and P2 is an abstraction of the protonotion consisting of P1 without that enveloped P3
    {e.g., 'choice using boolean start' is an abstraction of the notions 'choice using boolean brief start' and 'choice using boolean bold start' (by elision of a 'STYLE' from 9.1.1.a )}, or

  3. P2 is equivalent to {2.1.1.2.a}P1
{e.g., 'bold begin symbol' is an abstraction of 'bold begin symbol'} .

{For an example invoking all three rules, it may be observed that 'union of real integral mode defining indicator' is an abstraction of some 'union of integral real mode NEST defining identifier with letter a' {4.8.1.a}. Note, however, that 'choice using union of integral real mode brief start' is not an abstraction of the notion 'choice using union of integral real boolean mode brief start', because the 'boolean' that has apparently been elided is not an enveloped 'MOID' of that notion.}

c) The "elidible hypernotions" mentioned in section b above are the following:

"STYLE" • "TALLY" • "LEAP" • "DEFIED" • "VICTAL" • "SORT" • "MOID" • "NEST" • "REFETY routine" • "label" • "with TAX" • "with DECSETY LABSETY" • "of DECSETY LABSETY" • "defining LAYER".

{Which one of several possible notions or symbols is the original of a construct designated by a given paranotion will be apparent from the context in which that paranotion appears. For example, when speaking of the formal-declarer of an identity-declaration, if the identity-declaration is one whose terminal production {1.1.3.2.f} happens to be REF REAL x = LOC REAL, then the original of that formal-declarer is some notion designated by 'formal reference to real NEST declarer'.}

{Since a paranotion designates a construct, all technical terms which are defined for constructs can be used with paranotions without formality.}

d) If two paranotions P and Q designate, respectively, two constructs S and T, and if S is a descendent of T, then P is termed a "constituent" of Q unless there exists some {intermediate construct} U such that

  1. S is a descendent of U,
  2. U is a descendent of T, and
  3. either P or Q could {equally well} designate U.
{Hence a (S1) is a constituent operand of the formula a * (b + 2 ↑ (i + j)) (T), but b (S2) is not, since it is a descendent of an intermediate formula b + 2 ↑ (i + j) (U), which is itself descended from T. Likewise, (b + 2 ↑ (i + j )) is a constituent closed-clause of the formula T, but the closed-clause (i + j) is not, because it is descended from an intermediate closed-clause. However, (i + j) is a constituent integral-closed-clause of T, because the intermediate closed-clause is, in fact, a real-closed-clause.
    
     formula
     a * (b + 2 ↑ (i + j))
      |
      --------------------
      |                  |
     operand            operand
     a                   (b + 2 ↑ (i + j))
                         |
                        (real-) closed-clause
                         (b + 2 ↑ (i + j))
                         |
                        formula
                        b + 2 ↑ (i + j)
                         |
                         --------------------
                         |                  |
                        operand            operand
                        b                  2 ↑ (i + j)
                                            |
                                           formula
                                            |
                                            --------------------
                                            |                  |
                                           operand            operand
                                           2                   (i + j)
                                                               |
                                                              (integral-) closed-clause
                                                              (i + j)
    
    
}

1.1.4.3. Undefined

a) If something is left "undefined" or is said to be "undefined", then this means that it is not defined by this Report alone and that, for its definition, information from outside this Report has to be taken into account.

{A distinction must be drawn between the yielding of an undefined value (whereupon elaboration continues with possibly unpredictable results) and the complete undefinedness of the further elaboration. The action to be taken in this latter case is at the discretion of the implementer, and may be some form of continuation (but not necessarily the same as any other implementer's continuation), or some form of interruption {2.1.4.3.h} brought about by some run-time check.}

b) If some condition is "required" to be satisfied during some elaboration then, if it is not so satisfied, the further elaboration is undefined.

c) A "meaningful" program is a program {2.2.1.a} whose elaboration is defined by this Report.

{Whether all programs, only particular-programs, only meaningful programs, or even only meaningful particular-programs are "Algol 68" programs is a matter for individual taste.}

1.1.5. Translations and variants

a) The definitive version D of this Report is written in English. A translation T of this Report into some other language is an acceptable translation if:

T defines the same set of production trees as D, except that

  1. the originals contained in each production tree of T may be different protonotions obtained by some uniform translation of the corresponding originals contained in the corresponding production tree of D, and
  2. descendents of those production trees need not be the same if their originals are predicates {1.3.2};
T defines the meaning {2.1.4.1.a} of each of its programs to be the same as that of the corresponding program defined by D;
T defines the same reference language {9.4} and the same standard environment {10} as D;
T preserves, under another mode of expression, the meaning of each section of D except that:
  1. different syntactic marks {1.1.3.1.a} may be used {with a correspondingly different metaproduction rule for "ALPHA" {1.3.1.B}} ;
  2. the method of derivation of the production rules {1.1.3.4} and their interpretation {1.1.3.2} may be changed to suit the peculiarities of the particular natural language {; e.g., in a highly inflected natural language, it may be necessary to introduce some inflections into the hypernotions, for which changes such as the following might be required:
    1. additional means for the creation of extra metaproduction rules {1.1.3.3.a};
    2. a more elaborate definition of "consistent substitute" {1.1.3.4.e};
    3. a more elaborate definition of "equivalence" between protonotions {2.1.1.2.a};
    4. different inflections for paranotions {1.1.4.2.a};
    }
  3. some pragmatic remarks {1.1.2} may be changed.

b) A version of this Report may, additionally, define a "variant of Algol 68" by providing:

  1. additional or alternative representations in the reference language {9.4},
  2. additional or alternative rules for the notion 'character glyph' {8.1.4.1.c} and for the metanotions "ABC" {9.4.2.1.L} and "STOP" {10.1.1.B},
  3. additional or alternative declarations in the standard environment which must, however, have the same meaning as the ones provided in D;
provided always that such additional or alternative items are delineated in the text in such a way that the original language, as defined in D, is still defined therein.

1.2. General metaproduction rules

{The reader may find it helpful to note that a metanotion ending in "ETY" always has "EMPTY" as one of the hypernotions on its right-hand side.}

1.2.1. Metaproduction rules of modes

A) MODE :: PLAIN ; STOWED ; REF to MODE ; PROCEDURE ; UNITED ; MU definition of MODE ; MU application.
B) PLAIN :: INTREAL ; boolean ; character.
C) INTREAL :: SIZETY integral ; SIZETY real.
D) SIZETY :: long LONGSETY ; short SHORTSETY ; EMPTY.
E) LONGSETY :: long LONGSETY ; EMPTY.
F) SHORTSETY :: short SHORTSETY ; EMPTY.
G) EMPTY :: .
H) STOWED :: structured with FIELDS mode ; FLEXETY ROWS of MODE.
I) FIELDS :: FIELD ; FIELDS FIELD.
J) FIELD :: MODE field TAG {942A} .
K) FLEXETY :: flexible ; EMPTY.
L) ROWS :: row ; ROWS row.
M) REF :: reference ; transient reference.
N) PROCEDURE :: procedure PARAMETY yielding MOID.
O) PARAMETY :: with PARAMETERS ; EMPTY.
P) PARAMETERS :: PARAMETER ; PARAMETERS PARAMETER.
Q) PARAMETER :: MODE parameter.
R) MOID :: MODE ; void.
S) UNITED :: union of MOODS mode.
T) MOODS :: MOOD ; MOODS MOOD.
U) MOOD :: PLAIN ; STOWED ; reference to MODE ; PROCEDURE ; void.
V) MU :: muTALLY.
W) TALLY :: i ; TALLY i.

{The metaproduction rule for "TAG" is given in section 9.4.2.1. It suffices for the present that it produces an arbitrarily large number of terminal metaproductions.}

1.2.2. Metaproduction rules associated with phrases and coercion

A) ENCLOSED :: closed ; collateral ; parallel ; CHOICE {34A} ; loop.
B) SOME :: SORT MOID NEST.
C) SORT :: strong ; firm ; meek ; weak ; soft.

1.2.3. Metaproduction rules associated with nests

A) NEST :: LAYER ; NEST LAYER.
B) LAYER :: new DECSETY LABSETY.
C) DECSETY :: DECS ; EMPTY.
D) DECS :: DEC ; DECS DEC.
E) DEC :: MODE TAG {942A} ; priority PRIO TAD {942F} ; MOID TALLY TAB {942A} ; DUO TAD {942F} ; MONO TAM {942K} .
F) PRIO :: i ; ii ; iii ; iii i ; iii ii ; iii iii ; iii iii i ; iii iii ii ; iii iii iii.
G) MONO :: procedure with PARAMETER yielding MOID.
H) DUO :: procedure with PARAMETER1 PARAMETER2 yielding MOID.
I) LABSETY :: LABS ; EMPTY.
J) LABS :: LAB ; LABS LAB.
K) LAB :: label TAG {942A} .

{The metaproduction rules for "TAB", "TAD" and "TAM" are given in section 9.4.2.1 . It suffices for the present that each of them produces an arbitrarily large number of terminal metaproductions, none of which is a terminal metaproduction of "TAG".}

{"Well, 'slithy' means 'lithe and slimy'. ...
You see it's like a portmanteau - there are
two meanings packed up into one word."
Through the Looking Glass, Lewis Carroll.}

1.3. General hyper-rules

{Predicates are used in the syntax to enforce certain restrictions on the production trees, such as that each applied-indicator should identify a uniquely determined defining-indicator. A more modest use is to reduce the number of hyper-rules by grouping several similar cases as alternatives in one rule. In these cases predicates are used to test which alternative applies.}

1.3.1. Syntax of general predicates

A) NOTION :: ALPHA ; NOTION ALPHA.
B) ALPHA :: a ; b ; c ; d ; e ; f ; g ; h ; i ; j ; k ; l ; m ; n ; o ; p ; q ; r ; s ; t ; u ; v ; w ; x ; y ; z.
C) NOTETY :: NOTION ; EMPTY.
D) THING :: NOTION ; (NOTETY1) NOTETY2 ; THING (NOTETY1) NOTETY2.
E) WHETHER :: where ; unless.
a) where true : EMPTY.
b) unless false : EMPTY.
c) where THING1 and THING2 : where THING1, where THING2.
d) where THING1 or THING2 : where THING1 ; where THING2.
e) unless THING1 and THING2 : unless THING1 ; unless THING2.
f) unless THING1 or THING2 : unless THING1, unless THING2.
g) WHETHER (NOTETY1) is (NOTETY2) : WHETHER (NOTETY1) begins with (NOTETY2) {h,i,j} and (NOTETY2) begins with (NOTETY1) {h,i,j}.
h) WHETHER (EMPTY) begins with (NOTION) {g,j} : WHETHER false {b,-}.
i) WHETHER (NOTETY) begins with (EMPTY) {g,j} : WHETHER true {a,-}.
j) WHETHER (ALPHA1 NOTETY1) begins with (ALPHA2 NOTETY2) {g,j,m} : WHETHER (ALPHA1) coincides with (ALPHA2) in (abcdefghijklmnopqrstuvwxyz) {k,l,-} and (NOTETY1) begins with (NOTETY2) {h,i,j}.
k) where (ALPHA) coincides with (ALPHA) in (NOTION) {j} : where true {a}.
l) unless (ALPHA1) coincides with (ALPHA2) in (NOTION) {j} : where (NOTION) contains (ALPHA1 NOTETY ALPHA2) {m} or (NOTION) contains (ALPHA2 NOTETY ALPHA1) {m}.
m) WHETHER (ALPHA NOTETY) contains (NOTION) {l,m} : WHETHER (ALPHA NOTETY) begins with (NOTION) {j} or (NOTETY) contains (NOTION) {m,n}.
n) WHETHER (EMPTY) contains (NOTION) {m} : WHETHER false {b,-}.

{The small syntactic marks " (" and ")" are used to ensure, in a simple way, the unambiguous application of these predicates.}

1.3.2. The holding of predicates

A "predicate" is a protonotion which begins with 'where' or 'unless' {unified into 'WHETHER'} . For a predicate P, either one or more production trees may be produced {1.1.3.2.f} {all of which are then invisible}, in which case P "holds", or no production tree may be produced {since each attempt to produce one runs into blind alleys}, and then P "does not hold".

{For example, the predicate 'where (ab) is (ab)' holds. Its production tree may be depicted thus:


'where (ab) is (ab)'
 |
'where (ab) begins with (ab) and (ab) begins with (ab)'
 |
 -------------------------------
 |                             |
'where (ab) begins with (ab)' 'where (ab) begins with (ab)'
 |                            (same as left branch)
 |
'where (a) coincides with (a) in (abc ...z) and (b) begins with (b)'
 |
 --------------------------------------------
 |                                           |
'where (a) coincides with (a) in (abc ...z)' |
 |                                           |
'where true'                                'where (b) begins with (b)'
                                             |
 ---------------------------------------------
 |                                           |
'where (b) coincides with (b) in (abc ...z)' |
 |                                           |
'where true'                                'where () begins with ()'
                                             |
                                            'where true'

If a predicate holds, then its production tree always terminates via 'where true' or 'unless false'. If it does not hold, then, in general, the blind alleys are 'where false' and 'unless true'. Although almost all the hyper-rules concerned are for hypernotions beginning with "WHETHER" and so provide, each time, production rules for pairs of predicates such as 'where THING1' and 'unless THING1', this does not mean that in each such case one of the pair must hold. For example, 'where digit four counts iii' {4.3.1.c} does not hold, but no care has been taken to make 'unless digit four counts iii' hold either, since there is no application for it in this Report.

In the semantics, no meaning is ascribed to constructs whose originals are predicates. They serve purely syntactical purposes.}

1.3.3. Syntax of general constructions

A) STYLE :: brief ; bold ; style TALLY.
a) NOTION option : NOTION ; EMPTY.
b) NOTION sequence {b} : NOTION ; NOTION, NOTION sequence {b}.
c) NOTION list {c} : NOTION ; NOTION, and also {94f} token, NOTION list {c}.
d) NOTETY STYLE pack : STYLE begin {94f,-} token, NOTETY, STYLE end {94f,-} token.
e) NOTION STYLE bracket : STYLE sub {94f,-} token, NOTION, STYLE bus {94f,-} token.
f) THING1 or alternatively THING2 : THING1 ; THING2.

{It follows from this syntax that production rules such as

    digit cypher sequence : digit cypher ; digit cypher, digit cypher sequence.
(which was used in the production of the example in 1.1.3.2.f, but for which no more explicit hyper-rule is given) are immediately available. Thus the number of hyper-rules actually written in this Report has been reduced and those that remain have, hopefully, been made more readable, since these general constructions are so worded as to suggest what their productions should be.

For this reason, cross-references {1.1.3.4.f} to these rules have been replaced by more helpful references; e.g., in 8.1.1.1.b, instead of "digit cypher sequence {133b} ", the more helpful "digit cypher {c} sequence" is given. Likewise, references within the general constructions themselves have been restricted to a bare minimum.}


«Table of contents»

2. The computer and the program

The meaning of a program in the strict language is explained in terms of a hypothetical computer which performs the set of actions {2.1.4} which constitute the elaboration {2.1.4.1} of that program. The computer deals with a set of "objects" {2.1.1}.

2.1. Terminology

{"When I use a word," Humpty Dumpty said, in rather a
scornful tone, "it means just what I choose it to mean
- neither more nor less."
Through the Looking-glass, Lewis Carroll.}

2.1.1. Objects

An "object" is a construct {1.1.3.2.e}, a "value" {2.1.1.1.a}, a "locale" {2.1.1.1.b}, an "environ" {2.1.1.1.c} or a "scene" {2.1.1.1.d}.

{Constructs may be classified as "external objects", since they correspond to the text of the program, which, in a more realistic computer, would be compiled into some internal form in which it could operate upon the "internal objects", namely the values, the locales, the environs and the scenes. However, the hypothetical computer has no need of a compilation phase, it being presumed able to examine the program and all of its descendent constructs at the same time as it is manipulating the internal objects.}

2.1.1.1. Values, locales, environs and scenes

a) A "value" is a "plain value" {2.1.3.1}, a "name" {2.1.3.2}, a "stowed value" (i.e., a "structured value" {2.1.3.3} or a "multiple value" {2.1.3.4} ) or a "routine" {2.1.3.5}.

{For example, a real number is a plain value. A special font is used for values appearing in the text of this Report, thus: 3.14, true. This is not to be confused with the italic and bold fonts used for constructs. This same special font is also used for letters designating such things as constructs and protonotions.}

b) A "locale" {is an internal object which} corresponds to some 'DECSETY LABSETY' {1.2.3.C,I}. A "vacant locale" is one for which that 'DECSETY LABSETY' is 'EMPTY'.

{Each 'QUALITY TAX' {4.8.1.F, G} enveloped by that 'DECSETY LABSETY' corresponds to a QUALITY-defining-indicator-with-TAX {i.e., to an identifier, operator or mode-indication} declared in the construct whose elaboration caused that locale to be created. Such a 'QUALITY TAX' may be made to "access" a value or a scene "inside" that locale {2.1.2.c}

A locale may be thought of as a number of storage cells, into which such accessed objects are placed.}

{The terminal metaproductions of the metanotions "DEC", "LAB" and "FIELD" (or of the more frequently used "PROP", which includes them all) are all of the form 'QUALITY TAX'. These "properties" are used in the syntax and semantics concerned with nests and locales in order to associate, in a particular situation, some quality with that 'TAX'.}

c) An "environ" is either empty, or is composed of an environ and a locale.

{Hence, each environ is derived from a series of other environs, stemming ultimately from the empty "primal environ" in which the program is elaborated {2.2.2.a}.}

d) A "scene" S is an object which is composed of a construct C {1.1.3.2.e} and an environ E. C is said to be the construct, and E the environ, "of" S.

{Scenes may be accessed inside locales {2.1.2.c} by 'LAB's or 'DEC's arising from label-identifiers or from mode-indications, and they may also be values {2.1.3.5}.}

2.1.1.2. Modes

{Each value has an attribute, termed its "mode", which defines how that value relates to other values and which actions may be applied to it. This attribute is described, or "spelled", by means of some 'MOID' {1.2.1.R} (thus there is a mode spelled 'real', and there is a mode spelled 'structured with real field letter r letter e real field letter i letter m mode'). Since it is intended that the modes specified by the mode-indications A and B in

MODE A = STRUCT (REF A b),
MODE B = STRUCT (REF STRUCT (REF B b) b)
should in fact be the same mode, it is necessary that both the 'MOID'
TAB'mui definition of structured with reference to mui application field letter b mode'
and the 'MOID'
TAB'muii definition of structured with reference to structured with reference to muii application field letter b mode field letter b mode'
(and indeed many others) should be alternative spellings of that same mode. Similarly, the mode specified by the declarer UNION (INT, REAL) may be spelled as either 'union of integral real mode' or 'union of real integral mode'. All those 'MOID's which are spellings of one same mode are said to be "equivalent to" one another {a}.

Certain 'MOID's, such as 'reference to muiii application', 'reference to muiiii definition of reference to muiiii application', 'union of real reference to real mode', and 'structured with integral field letter a real field letter a mode', are ill formed {7.4, 4.7.1.f, 4.8.1.c} and do not spell any mode.

Although for most practical purposes a "mode" can be regarded as simply a 'MOID', its rigorous definition therefore involves the whole class of 'MOID's, equivalent to each other, any of which could describe it.}

a) 'MOID1' {1.2.1.R} is "equivalent to" 'MOID2' if the predicate 'where MOID1 equivalent MOID2' {7.3.1.a} holds {1.3.2}.

{A well formed 'MOID' is always equivalent to itself: 'union of integral real mode' is equivalent to 'union of real integral mode'.}

A protonotion P is "equivalent to" a protonotion Q if it is possible to transform a copy Pc of P into at copy Qc of Q in the following step:

    Step : If Pc is not identical to Qc, then some 'MOID1' contained in Pc, but not within any {larger} 'MOID2' contained in Pc, is replaced by some equivalent 'MOID', and the Step is taken again.
{Thus 'union of integral real mode identifier' is equivalent to 'union of real integral mode identifier'.}

b) A "mode" is a class C of 'MOID's such that each member of C is equivalent {a} to each other member of C and also to itself {in order to ensure well formedness}, but not to any 'MOID1' which is not a member of C.

{However, it is possible (except when equivalence of modes is specifically under discussion) to discuss a mode as if it were simply a terminal metaproduction of "MOID", by virtue of the abbreviation to be given in 2.1.5.f .}

c) Each value is of one specific mode.

{For example, the mode of the value 3.14 is 'real'. However, there are no values whose mode begins with 'union of', 'transient reference to' or 'flexible ROWS of' (see 2.1.3.6 ).}

2.1.1.3. Scopes

{A value V may "refer to" {2.1.2.e}, or be composed from {2.1.1.1.d} another internal object O (e.g., a name may refer to a value; a routine, which is a scene, is composed, in part, from an environ). Now the lifetime of the storage cells containing {2.1.3.2.a} or implied by {2.1.1.1.b} O may be limited (in order that they may be recovered after a certain time), and therefore it must not be possible to preserve V beyond that lifetime, for otherwise an attempt to reach some no-longer-existent storage cell via V might still be made. This restriction is expressed by saying that, if V is to be "assigned" {5.2.1.2.b} to some name W, then the "scope" of W must not be "older" than the scope of V. Thus, the scope of V is a measure of the age of those storage cells, and hence of their lifetime.}

a) Each value has one specific "scope" {which depends upon its mode or upon the manner of its creation; the scope of a value is defined to be the same as that of some environ}.

b) Each environ has one specific "scope". {The scope of each environ is "newer" {2.1.2.f} than that of the environ from which it is composed {2.1.1.1.c}.}

{The scope of an environ is not to be confused with the scopes of the values accessed inside its locale. Rather, the scope of an environ is used when defining the scope of scenes for which it is necessary {7.2.2.c} or of the yields of generators for which it is "local" {5.2.3.2.b}. The scope of an environ is defined relative {2.1.2.f} to the scope of some other environ, so that hierarchies of scopes are created depending ultimately upon the scope of the primal environ {2.2.2.a}.}

2.1.2. Relationships

a) Relationships either are "permanent", i.e., independent of the program and of its elaboration, or actions may cause them to "hold" or to cease to hold. Relationships may also be "transitive"; i.e., if "*" is such a relationship and A*B and B*C hold, then A*C holds also.

b) "To be the yield of" is a relationship between a value and an action, viz., the elaboration of a scene. This relationship is made to hold upon the completion of that elaboration {2.1.4.1.b}.

c) "To access" is a relationship between a 'PROP' {4.8.1.E} and a value or a scene V which may hold "inside" some specified locale L {whose 'DECSETY LABSETY' envelops 'PROP'} . This relationship is made to hold when 'PROP' is "made to access" V inside L {3.5.2.Step 4, 4.8.2.a} and it then holds also between any 'PROP1' equivalent to {2.1.1.2.a} 'PROP' and V inside L.

d) The permanent relationships between values are: "to be of the same mode as" {2.1.1.2.c}, "to be smaller than", "to be widenable to", "to be lengthenable to" {2.1.3.1.e} and "to be equivalent to" {2.1.3.1.g}. If one of these relationships is defined at all for a given pair of values, then it either holds or does not hold permanently. These relationships are all transitive.

e) "To refer to" is a relationship between a "name" {2.1.3.2.a} N and some other value. This relationship is made to hold when N is "made to refer to" that value and ceases to hold when N is made to refer to some other value.

f) There are three transitive relationships between scopes, viz., a scope A {2.1.1.3} may be either "newer than", or "the same as" or "older than" a scope B. If A is newer than B, then B is older than A and vice-versa. If A is the same as B, then A is neither newer nor older than B {but the converse is not necessarily true, since the relationship is not defined at all for some pairs of scopes}.

g) "To be a subname of" is a relationship between a name and a "stowed name" {2.1.3.2.b}. This relationship is made to hold when that stowed name is "endowed with subnames" {2.1.3.3.e, 2.1.3.4.g} or when it is "generated" {2.1.3.4.j, l}, and it continues to hold until that stowed name is endowed with a different set of subnames.

2.1.3. Values

2.1.3.1. Plain values

a) A plain value is either an "arithmetic value", i.e., an "integer" or a "real number", or is a "truth value" {f}, a "character" {g} or a "void value" {h}.

b) An arithmetic value has a "size", i.e., an integer characterizing the degree of discrimination with which it is kept in the computer.

c) The mode of an integer or of a real number of size n is, respectively, some 'SIZETY integral' or 'SIZETY real' where, if n is positive (zero, negative), that 'SIZETY' is n times 'long' (is empty, is -n times 'short').

d) The number of integers or of real numbers of a given size that can be distinguished increases (decreases) with that size until a certain size is reached, viz., the "number of extra lengths" (minus the "number of extra shorths") of integers or of real numbers, respectively, {10.2.1.a, b, d, e} after which it is constant.

{Taking Three as the subject to reason about -
A convenient number to state -}

e) For the purpose of explaining the meaning of the widening coercion and of the operators declared in the standard-prelude, the following properties of arithmetic values are assumed:

  • for each pair of integers or of real numbers of the same size, the relationship "to be smaller than" is defined with its usual mathematical meaning {10.2.3.3.a, 10.2.3.4.a};
  • for each pair of integers of the same size, a third distinguishable integer of that size may exist, the first integer "minus" the other {10.2.3.3.g};
    {We add Seven, and Ten, and then multiply out
    By One Thousand diminished by Eight.}

  • for each pair of real numbers of the same size, three distinguishable real numbers of that size may exist, the first real number "minus" ("times", "divided by") the other one {10.2.3.4.g, l, m};
  • in the foregoing, the terms "minus", "times" and "divided by" have their usual mathematical meaning but, in the case of real numbers, their results are obtained "in the sense of numerical analysis", i.e., by performing those operations on numbers which may deviate slightly from the given ones {; this deviation is left undefined in this Report};
    {The result we proceed to divide, as you see,
    By Nine Hundred and Ninety and Two}

  • each integer of a given size is "widenable to" a real number close to it and of that same size {6.5};
  • each integer (real number) of a given size can be "lengthened to" an integer (real number) close to it whose size is greater by one {10.2.3.3.q, 10.2.3.4.n}.

f) A "truth value" is either "true" or "false". Its mode is 'boolean'.

{Then subtract Seventeen, and the answer must be
Exactly and perfectly true.
The Hunting of the Snark, Lewis Carroll.}

g) Each "character" is "equivalent" to a nonnegative integer of size zero, its "integral equivalent" {10.2.1.n}; this relationship is defined only to the extent that different characters have different integral equivalents, and that there exists a "largest integral equivalent" {10.2.1.p}. The mode of a character is 'character'.

h) The only "void value" is "empty". Its mode is 'void'.

{The elaboration of a construct yields a void value when no more useful result is needed. Since the syntax does not provide for void-variables, void-identity-declarations or void-parameters, the programmer cannot make use of void values, except those arising from uniting {6.4}.}

i) The scope of a plain value is the scope of the primal environ {2.2.2.a}.

2.1.3.2. Names

{What's in a name? that which we call a
rose By any other name would smell as sweet.
Romeo and Juliet, William Shakespeare.}

a) A "name" is a value which can be "made to refer to" {d, 5.2.3.2.a, 5.2.1.2.b} some other value, or which can be "nil" {and then refers to no value}; moreover, for each mode beginning with 'reference to', there is exactly one nil name of that mode.

A name may be "newly created" {by the elaboration of a generator {5.2.3.2} or a rowed-to-FORM {6.6.2}, when a stowed name is endowed with subnames {2.1.3.3.e, 2.1.3.4.g} and, possibly, when a name is "generated" {2.1.3.4.j, l}}. The name so created is different from all names already in existence.

{A name may be thought of as the address of the storage cell or cells, in the computer, used to contain the value referred to. The creation of a name implies the reservation of storage space to hold that value.}

b) The mode of a name N is some 'reference to MODE' and any value which is referred to by N must be "acceptable to" {2.1.3.6.d} that 'MODE'. If 'MODE' is some 'STOWED', then N is said to be a "stowed name".

c) The scope of a name is the scope of some specific environ {usually the "local environ" {5.2.3.2.b} of some generator} . The scope of a name which is nil is the scope of the primal environ {2.2.2.a}.

d) If N is a stowed name referring to a structured (multiple) value V {2.1.3.3, 2.1.3.4}, and if a subname {2.1.2.g} of N selected {2.1.3.3.e, 2.1.3.4.g} by a 'TAG' (an index) I is made to refer to a {new} value X, then N is made to refer to a structured (multiple) value which is the same as V except for its field (element) selected by I which is {now made to be} X.

{For the mode of a subname, see 2.1.3.3.d and 2.1.3.4.f.}

2.1.3.3. Structured values

a) A "structured value" is composed of a sequence of other values, its "fields", each of which is "selected" {b} by a specific 'TAG' {9.4.2.1.A}. {For the selection of a field by a field-selector, see 2.1.5.g .}

{The ordering of the fields of a structured value is utilized in the semantics of structure-displays {3.3.2.b} and format-texts {10.3.4}, and in straightening {10.3.2.3.c}.}

b) The mode of a structured value V is some 'structured with FIELDS mode'. If the n-th 'FIELD' enveloped by that 'FIELDS' is some 'MODE field TAG', then the n-th field of V is "selected" by 'TAG' and is acceptable to {2.1.3.6.d} 'MODE'.

c) The scope of a structured value is the newest of the scopes of its fields.

d) If the mode of a name N {referring to a structured value} is some 'reference to structured with FIELDS mode', and if the predicate 'where MODE field TAG resides in FIELDS' holds {7.2.1.b, c}, then the mode of the subname of N selected {e} by 'TAG' is 'reference to MODE'.

e) When a name N which refers to a structured value V is "endowed with subnames" {e, 2.1.3.4.g, 4.4.2.b, 5.2.3.2.a}, then,

For each 'TAG' selecting a field F in V,

  • a new subname M is created of the same scope as N;
  • M is made to refer to F;
  • M is said to be the name "selected" by 'TAG' in N;
  • if M is a stowed name {2.1.3.2.b}, then it is itself endowed with subnames {e, 2.1.3.4.g}.

2.1.3.4. Multiple values

a) A "multiple value" {of n dimensions} is composed of a "descriptor" and a sequence of other values, its "elements", each of which may be "selected" by a specific n-tuple of integers, its "index".

b) The "descriptor" is of the form
( (l1, u1), (l2, u2), ..., (ln, un))
where each (li, ui), i = 1, ...,n, is a "bound pair" of integers in which li is the i-th "lower bound" and ui is the i-th "upper bound".

c) If for any i, i = 1, ..., n, ui < li, then the descriptor is said to be "flat" and there is one element, termed a "ghost element" {, and not selected by any index; see also {5.2.1.2.b}} ; otherwise, the number of elements is (u1 - l1 + 1) × (u2 - l2 + 1) × ... × (un - ln + 1) and each is selected by a specific index r1, ..., rn where li ≤ ri ≤ ui, i = 1, ..., n.

d) The mode of a multiple value V is some 'ROWS of MODE', where that 'ROWS' is composed of as many times 'row' as there are bound pairs in the descriptor of V and where each element of V is acceptable to {2.1.3.6.d} that 'MODE'.

{For example, given [] UNION (INT, REAL) ruir = (1, 2.0), the mode of the yield of ruir is 'row of union of integral real mode', the mode of its first element is 'integral' and that of its second element is 'real'.}

e) The scope of a multiple value is the newest of the scopes of its elements, if its descriptor is not flat, and, otherwise, is the scope of the primal environ {2.2.2.a}.

f) A multiple value, of mode 'ROWS of MODE', may be referred to either by a "flexible" name of mode 'reference to flexible ROWS of MODE1', or by a "fixed" name of mode 'reference to ROWS of MODE1' where {in either case} 'MODE1' "deflexes" {2.1.3.6.b} to 'MODE'.

{The difference implies a possible difference in the method whereby the value is stored in the computer. The flexible case must allow a multiple value with different bounds to be assigned {5.2.1.2.b} to that name, whereas the fixed case can rely on the fact that those bounds will remain fixed during the lifetime of that name. Note that the "flexibility" is a property of the name; the underlying multiple value is the same value in both cases.}

If the mode of a name N {referring to a multiple value} is some 'reference to FLEXETY ROWS of MODE', then the mode of each subname of N is 'reference to MODE'.

g) When a name N which refers to a multiple value V is "endowed with subnames" {g, 2.1.3.3.e, 4.4.2.b, 5.2.1.2.b, 5.2.3.2.a}, then,
For each index selecting an element E of V,

  • a new subname M is created of the same scope as N;
  • M is made to refer to E;
  • M is said to be the name "selected" by that index in N;
  • if M is a stowed name {2.1.3.2.b}, then it is itself endowed with subnames {g, 2.1.3.3.e}.

{In addition to the selection of an element {a} or a name {g} by means of an index, it is also possible to select a value, or to generate a new name referring to such a value, by means of a trim {h, i, j} or a 'TAG' {k, l}. Both indexes and trims are used in the elaboration of slices {5.3.2.2}.}

h) A "trim" is an n-tuple, each element of which is either an integer {corresponding to a subscript} or a triplet (l, u, d) {corresponding to a trimmer or a revised-lower-bound-option}, such that at least one of those elements is a triplet {if all the elements are integers, then the n-tuple is an index {a}}. Each element of such a triplet is either an integer or is "absent".

{A trim (or an index) is yielded by the elaboration of an indexer {5.3.2.2.b}.}

i) The multiple value W {of m dimensions} "selected" by a trim T in a multiple value V {of n dimensions, 1 ≤ m ≤ n} is determined as follows:

  • Let T be composed of integers and triplets Ti, i = 1, ... n, of which m are actually triplets; let the j-th triplet be (lj, uj, dj), j = 1, ... m;
  • W is composed of
    1. a descriptor ( (l1 - d1, u1 - d1), (l2 - d2, u2 - d2), ..., (lm - dm, um - dm);
    2. elements of V, where the element, if any, selected in W by an index (w1, ..., wm) {lj - dj ≤ wj ≤ uj - dj} is that selected in V by the index (v1, ..., vn) determined as follows:
      For i = 1, ..., n,
        Case A: Ti is an integer:
        • vi = Ti;
        Case B: Ti is the j-th triplet (lj, uj, dj) of T:
        • vi = wj + dj.

j) The name M "generated" by a trim T from a name N which refers to a multiple value V is a {fixed} name, of the same scope as N, {not necessarily newly created} which refers to the multiple value W selected {i} by T in V. Each subname of M, as selected by an index IW, is one of the {already existing} subnames of N, as selected by an index IV, where each IV is determined from T and the corresponding IW using the method given in the previous sub-section.

k) The multiple value W "selected" by a 'TAG' in a multiple value V {each of whose elements is a structured value} is composed of

  1. the descriptor of V, and
  2. the fields selected by 'TAG' in the elements of V, where the element, if any, selected in W by an index I is the field selected by 'TAG' in the element of V selected by I.

l) The name M "generated" by a 'TAG' from a name N which refers to a multiple value V {each of whose elements is a structured value} is a {fixed} name, of the same scope as N, {not necessarily newly created} which refers to the multiple value selected {k} by 'TAG' in V. Each subname of M selected by an index I is the {already existing} name selected {2.1.3.3.e} by 'TAG' in the subname of N selected {g} by I.

2.1.3.5. Routines

a) A "routine" is a scene {2.1.1.1.d} composed of a routine-text {5.4.1.1.a,b} together with an environ {2.1.1.1.c}.

{A routine may be "called" {5.4.3.2.b}, whereupon the unit of its routine-text is elaborated.}

b) The mode of a routine composed of a PROCEDURE-routine-text is 'PROCEDURE'.

c) The scope of a routine is the scope of its environ.

2.1.3.6. Acceptability of values

a) {There are no values whose mode begins with 'union of'. There exist names whose modes begin with 'reference to union of', e.g., u in UNION (INT, REAL) u; . Here, however, u, whose mode is 'reference to union of integral real mode', refers either to a value whose mode is 'integral' or to a value whose mode is 'real'. It is possible to discover which of these situations obtains, at a given moment, by means of a conformity-clause {3.4.1.q}.}

The mode 'MOID' is "united from" the mode 'MOOD' if 'MOID' is some 'union of MOODSETY1 MOOD MOODSETY2 mode'.

b) {There are no values whose mode begins with 'flexible'. There exist flexible names whose modes begin with 'reference to flexible', e.g., a1 in FLEX [1: n] REAL a1; . Here a1, whose mode is 'reference to flexible row of real', refers to a multiple value whose mode is 'row of real' (see also 2.1.3.4.f ). In general, there exist values only for those modes obtainable by "deflexing".}

The mode 'MOID1' "deflexes" to the mode 'MOID2' if the predicate 'where MOID1 deflexes to MOID2' holds {4.7.1.a, b, c}.
{The deflexing process obtains 'MOID2' by removing all 'flexible's contained at positions in 'MOID1' where they are not also contained in any 'REF to MOID3'. Thus
'structured with flexible row of character field letter a mode',
which is not the mode of any value, deflexes to
'structured with row of character field letter a mode'
which is therefore the mode of a value referable to by a flexible name of mode
'reference to structured with flexible row of character field letter a mode'.
This mode is already the mode of a name and therefore it cannot be deflexed any further.}

c) {There are no names whose mode begins with 'transient reference to'.
The yield of a transient-reference-to-MODE-FORM is a "transient name" of mode 'reference to MODE', but, there being no transient-reference-to-MODE-declarators in the language {4.6.1}, the syntax ensures that transient names can never be assigned, ascribed or yielded by the calling of a routine.
E.g., xx := a1 [i] is not an assignation because xx is not a reference-to-transient-reference-to-real-identifier. Transient names originate from the slicing, multiple selection or rowing of a flexible name.}

d) A value of mode M1 is "acceptable to" a mode M2 if

  1. M1 is the same as M2, or
  2. M2 is united {a} from M1 {thus the mode specified by UNION (REAL, INT) accepts values whose mode is that specified by either REAL or INT}, or
  3. M2 deflexes {b} to M1 {thus the mode 'flexible row of real' (a mode of which there are no values) accepts values such as the yield of the actual-declarer FLEX [1 : n] REAL which is a value of mode 'row of real'}, or
  4. M1 is some 'reference to MODE' and M2 is 'transient reference to MODE' {thus the mode 'transient reference to real' accepts values (such as the yield of a1 [i]) whose mode is 'reference to real'} .
{See 2.1.4.1.b for the acceptability of the yield of a scene.}

2.1.4. Actions

{Suit the action to the word,
the word to the action.
Hamlet, William Shakespeare.}

2.1.4.1. Elaboration

a) The "elaboration" of certain scenes {those whose constructs are designated by certain paranotions} is specified in the sections of this Report headed "Semantics", which describe the sequence of "actions" which are to be carried out during the elaboration of each such scene.
{Examples of actions which may be specified are:

  • the causing to hold of relationships,
  • the creation of new names, and
  • the elaboration of other scenes.}
The "meaning" of a scene is the effect of the actions carried out during its elaboration. Any of these actions or any combination thereof may be replaced by any action or combination which causes the same effect.

b) The elaboration of a scene S may "yield" a value. If the construct of S is a MOID-NOTION, then that value is, unless otherwise specified, {of such a mode that it is} acceptable to {2.1.3.6.d} 'MOID'.
{This rule makes it possible, in the semantics, to discuss yields without explicitly prescribing their modes.}

c) If the elaboration of some construct A in some environ E is not otherwise specified in the semantics of this Report, and if B is the only direct descendent of A which needs elaboration {see below}, then the elaboration of A in E consists of the elaboration of B in E and the yield, if any, of A is the yield, if any, of B {; this automatic elaboration is termed the "pre-elaboration" of A in E} .
A construct needs no elaboration if it is invisible {1.1.3.2.h}, if it is a symbol {9.1.1.h}, or if its elaboration is not otherwise specified in the semantics of this Report and none of its direct descendents needs elaboration.
{Thus the elaboration of the reference-to-real-closed-clause {3.1.1.a} (x := 3.14) is (and yields the same value as) the elaboration of its constituent reference-to-real-serial-clause {3.2.1.a} x := 3.14.}

2.1.4.2. Serial and collateral actions

a) An action may be "inseparable", "serial" or "collateral". A serial or collateral action consists of one or more other actions, termed its "direct actions". An inseparable action does not consist of other actions {; what actions are inseparable is left undefined by this Report}.

b) A "descendent action" of another action B is a direct action either of B, or of a descendent action of B.

c) An action A is the "direct parent" of an action B if B is a direct action {a} of A.

d) The direct actions of a serial action S take place one after the other; i.e., the completion {2.1.4.3.c, d} of a direct action of S is followed by the initiation {2.1.4.3.b, c} of the next direct action, if any, of S. {The elaboration of a scene, being in general composed of a sequence of actions, is a serial action.}

e) The direct actions of a collateral action are merged in time; i.e., one of its descendent inseparable actions which, at that moment, is "active" {2.1.4.3.a} is chosen and carried out, upon the completion {2.1.4.3.c} of which another such action is chosen, and so on {until all are completed}.

If two actions {collateral with each other} have been said to be "incompatible with" {10.2.4} each other, then {they shall not be merged; i.e.,} no descendent inseparable action of the one shall (then the one {if it is already inseparable} shall not) be chosen if, at that moment, the other is active and one or more, but not all, of its descendent inseparable actions have already been completed; otherwise, the method of choice is left undefined in this Report.

f) If one or more scenes are to be "elaborated collaterally", then this elaboration is the collateral action consisting of the {merged} elaboration of those scenes.

2.1.4.3. Initiation, completion and termination

a) An action is either "active" or "inactive".

An action becomes active when it is "initiated" {b, c} or "resumed" {g} and it becomes inactive when it is "completed" {c, d}, "terminated" {e}, "halted" {f} or "interrupted" {h}.

b) When a serial action is "initiated", then the first of its direct actions is initiated. When a collateral action is "initiated", then all of its direct actions are initiated.

c) When an inseparable action is "initiated", it may then be carried out {see 2.1.4.2.e}, whereupon it is "completed".

d) A serial action is "completed" when its last direct action has been completed. A collateral action is "completed" when all of its direct actions have been completed.

e) When an action A {whether serial or collateral} is "terminated", then all of its direct actions {and hence all of its descendent actions} are terminated {whereupon another action may be initiated in its place} . {Termination of an action is brought about by the elaboration of a jump {5.4.4.2}.}

f) When an action is "halted", then all of its active direct actions {and hence all of its active descendent actions} are halted. {An action may be halted during a "calling" of the routine yielded by the operator DOWN {10.2.4.d}, whereupon it may subsequently be resumed during a calling of the routine yielded by the operator UP {10.2.4.e}.}

If, at any time, some action is halted and it is not descended from a "process" of a "parallel action" {10.2.4} of whose other process (es) there still exist descendent active inseparable actions, then the further elaboration is undefined. {Thus it is not defined that the elaboration of the collateral-clause in

BEGIN SEMA sergei = LEVEL 0;
   (PAR BEGIN (DOWN sergei; print (pokrovsky)), SKIP END,
      (read (pokrovsky); UP sergei))
END
will ever be completed.}

g) When an action A is "resumed", then those of its direct actions which had been halted consequent upon the halting of A are resumed.

h) An action may be "interrupted" by an event {e.g., "overflow"} not specified by the semantics of this Report but caused by the computer if its limitations {2.2.2.b} do not permit satisfactory elaboration. When an action is interrupted, then all of its direct actions, and possibly its direct parent also, are interrupted. {Whether, after an interruption, that action is resumed, some other action is initiated or the elaboration of the program ends, is left undefined by this Report.}

{The effect of the definitions given above is as follows:
During the elaboration of a program {2.2.2.a} the elaboration of its closed-clause in the empty primal environ is active. At any given moment, the elaboration of one scene may have called for the elaboration of some other scene or of several other scenes collaterally. If and when the elaboration of that other scene or scenes has been completed, the next step of the elaboration of the original scene is taken, and so on until it, in turn, is completed.
It will be seen that all this is analogous to the calling of one subroutine by another; upon the completion of the execution of the called subroutine, the execution of the calling subroutine is continued; the semantic rules given in this Report for the elaboration of the various paranotions correspond to the texts of the subroutines; the semantic rules may even, in suitable circumstances, invoke themselves recursively (but with a different construct or in a different environ on each occasion).
Thus there exists, at each moment, a tree of active actions descended {2.1.4.2.b} from the elaboration of the program.}

2.1.5. Abbreviations

{In order to avoid some long and turgid phrases which would otherwise have been necessary in the Semantics, certain abbreviations are used freely throughout the text of this Report.}

a) The phrase "the A of B", where A and B are paranotions, stands for "the A which is a direct descendent {1.1.3.2.f} of B".
{This permits the abbreviation of "direct descendent of" to "of" or "its", e.g., in the assignation {5.2.1.1.a} i := 1, i is "its" destination (or i is the, or a, destination "of" the assignation i := 1), whereas i is not a destination of the serial-clause i := 1; j := 2 (although it is a constituent destination {1.1.4.2.d} of it).}

b) The phrase "C in E", where C is a construct and E is an environ, stands for "the scene composed {2.1.1.1.d} of C and E". It is sometimes even further shortened to just "C" when it is clear which environ is meant.
{Since the process of elaboration {2.1.4.1.a} may be applied only to scenes, this abbreviation appears most frequently in forms such as "A loop-clause C, in an environ E1, is elaborated ... " {3.5.2} and "An assignation A is elaborated ... " (5.2.1.2.a, where it is the elaboration of A in any appropriate environ that is being discussed).}

c) The phrase "the yield of S", where S is a scene whose elaboration is not explicitly prescribed, stands for "the yield obtained by initiating the elaboration of S and awaiting its completion".
{Thus the sentence {3.2.2.c} :

    "W is the yield of that unit;"
(which also makes use of the abbreviation defined in b above) is to be interpreted as meaning:
    "W is the yield obtained upon the completion of the elaboration, hereby initiated, of the scene composed of that unit and the environ under discussion;" .
}

d) The phrase "the yields of S1, ..., Sn ", where S1, ..., Sn are scenes whose elaboration is not explicitly prescribed, stands for "the yields obtained by initiating the collateral elaboration {2.1.4.2.f} of S1, ..., Sn and awaiting its completion {which implies the completion of the elaboration on them all} ".
If some or all of S1, ..., Sn are described as being, in some environ, certain constituents of some construct, then their yields are to be considered as being taken in the textual order {1.1.3.2.i} of those constituents within that construct.
{Thus the sentence {3.3.2.b} :

    "let V1, ..., Vm be the {collateral} yields of the constituent units of C;"
is to be interpreted as meaning:
    "let V1, ..., Vm be the respective yields obtained upon the completion of the collateral elaboration, hereby initiated, of the scenes composed of the constituent units of C, considered in their textual order, together with the environ in which C was being elaborated;" .
}

e) The phrase "if A is B", where A and B are hypernotions, stands for "if A is equivalent {2.1.1.2.a} to B".
{Thus, in "Case C: 'CHOICE' is some 'choice using UNITED'" {3.4.2.b}, it matters not whether 'CHOICE' happens to begin with 'choice using union of' or with some 'choice using MU definition of union of'.}

f) The phrase "the mode is A", where A is a hypernotion, stands for "the mode {is a class of 'MOID's which} includes A".
{This permits such shortened forms as "the mode is some 'structured with FIELDS mode'", "the mode begins with 'union of'", and "the mode envelops a 'FIELD'"; in general, a mode may be specified by quoting just one of the 'MOID's included in it.}

g) The phrase "the value selected (generated) by the field-selector F" stands for "if F is a field-selector-with-TAG {4.8.1.f}, then the value selected {2.1.3.3.a, e, 2.1.3.4.k} (generated {2.1.3.4.l} ) by that 'TAG'".

2.2. The program

2.2.1. Syntax

a) program : strong void new closed clause {31a} . {See also 10.1 .}

2.2.2. Semantics

{"I can explain all the poems that ever were invented -
and a good many that haven't been invented just yet."
Through the Looking-glass, Lewis Carroll.}

a) The elaboration of a program is the elaboration of its strong-void-new-closed-clause in an empty environ {2.1.1.1.c} termed the "primal environ".
{Although the purpose of this Report is to define the meaning of a particular-program (10.1.1.g), that meaning is established only by first defining the meaning of a program in which that particular-program is embedded (10.1.2).}

{In this Report, the syntax says which sequences of symbols are terminal productions of 'program', and the semantics which actions are performed by the computer when elaborating a program. Both syntax and semantics are recursive. Though certain sequences of symbols may be terminal productions of 'program' in more than one way (see also 1.1.3.2.f ), this syntactic ambiguity does not lead to a semantic ambiguity.}

b) In Algol 68, a specific syntax for constructs is provided which, together with its recursive definition, makes it possible to describe and to distinguish between arbitrarily large production trees, to distinguish between arbitrarily many different values of a given mode (except certain modes like 'boolean' and 'void') and to distinguish between arbitrarily many modes, which allows arbitrarily many objects to exist within the computer and which allows the elaboration of a program to involve an arbitrarily large, not necessarily finite, number of actions. This is not meant to imply that the notation of the objects in the computer is that used in this Report nor that it has the same possibilities. It is not assumed that these two notations are the same nor even that a one-to-one correspondence exists between them; in fact, the set of different notations of objects of a given category may be finite. It is not assumed that the computer can handle arbitrary amounts of presented information. It is not assumed that the speed of the computer is sufficient to elaborate a given program within a prescribed lapse of time, nor that the number of objects and relationships that can be established is sufficient to elaborate it at all.

c) A model of the hypothetical computer, using a physical machine, is said to be an "implementation" of Algol 68 if it does not restrict the use of the language in other respects than those mentioned above. Furthermore, if a language A is defined whose particular-programs are also particular-programs of a language B, and if each such particular-program for which a meaning is defined in A has the same defined meaning in B, then A is said to be a "sublanguage" of B, and B a "superlanguage" of A.
{Thus a sublanguage of Algol 68 might be defined by omitting some part of the syntax, by omitting some part of the standard-prelude, and/or by leaving undefined something which is defined in this Report, so as to enable more efficient solutions to certain classes of problem or to permit implementation on smaller machines.
Likewise, a superlanguage of Algol 68 might be defined by additions to the syntax, semantics or standard-prelude, so as to improve efficiency (by allowing the user to provide additional information) or to permit the solution of problems not readily amenable to Algol 68.}
A model is said to be an implementation of a sublanguage if it does not restrict the use of the sublanguage in other respects than those mentioned above.
{See 9.3.c for the term "implementation of the reference language".}

{A sequence of symbols which is not a particular-program but can be turned into one by deleting or inserting a certain number of symbols and not a smaller number could be regarded as a particular-program with that number of syntactical errors. Any particular-program that can be obtained by deleting or inserting that number of symbols may be termed a "possibly intended" particular-program. Whether a particular-program or one of the possibly intended particular-programs has the effect its author in fact intended it to have is a matter which falls outside this Report.}

{In an implementation, the particular-program may be "compiled", i.e., translated into an "object program" in the code of the physical machine. Under certain circumstances, it may be advantageous to compile parts of the particular-program independently, e.g., parts which are common to several particular-programs. If such a part contains applied-indicators which identify defining-indicators not contained in that part, then compilation into an efficient object program may be assured by preceding the part by a sequence of declarations containing those defining-indicators.}

{The definition of specific sublanguages and also the specification of actions not definable by any program (e.g., compilation or initiation of the elaboration) is not given in this Report. See, however, 9.2 for the suggested use of pragmats to control such actions.}


«Table of contents»

PART II - Fundamental Constructions

{This part presents the essential structure of programs:

  • the general rules for constructing them;
  • the ways of defining indicators and their properties, at each new level of construction;
  • the constructs available for programming primitive actions.}

3. Clauses

{Clauses provide
  • a hierarchical structure for programs,
  • the introduction of new ranges of definitions,
  • serial or collateral composition, parallelism, choices and loops.}

3.0.1. Syntax

a) *phrase : SOME unit {32d} ; NEST declaration of DECS {41a} .
b) *SORT MODE expression : SORT MODE NEST UNIT {5A} .
c) *statement : strong void NEST UNIT {5A} .
d) *MOID constant : MOID NEST DEFIED identifier with TAG {48a, b} ; MOID NEST denoter {80a} .
e) *MODE variable : reference to MODE NEST DEFIED identifier with TAG {43a, b} .
f) *NEST range : SOID NEST serial clause defining LAYER {32a} ; SOID NEST chooser CHOICE STYLE clause {34b} ; SOID NEST case part of choice using UNITED {34i} ; NEST STYLE repeating part with DEC {35e} ; NEST STYLE while do part {35f} ; PROCEDURE NEST routine text {541a, b} .

{NEST-ranges arise in the definition of "identification" {7.2.2.b}.}

3.0.2. Semantics

A "nest" is a 'NEST'. The nest "of" a construct is the 'NEST' enveloped by the original of that construct, but not by any 'defining LAYER' contained in that original.

{The nest of a construct carries a record of all the declarations forming the environment in which that construct is to be interpreted.
Those constructs which are contained in a range R, but not in any smaller range contained within R, may be said to comprise a "reach". All constructs in a given reach have the same nest, which is that of the immediately surrounding reach with the addition of one extra 'LAYER'. The syntax ensures {3.2.1.b , 3.4.1.i, j, k , 3.5.1.e, 5.4.1.1.b} that each 'PROP' {4.8.1.E} or "property" in the extra 'LAYER' is matched by a defining-indicator {4.8.1.a} contained in a definition in that reach.}

3.1. Closed clauses

{Closed-clauses are usually used to construct units from serial-clauses as, e.g.,

(REAL x; read (x); x) in
(REAL x; read (x); x) + 3.14.
}

3.1.1. Syntax

A) SOID :: SORT MOID.
B) PACK :: STYLE pack.
a) SOID NEST closed clause {22a , 5D, 551a, A341h, A349a} : SOID NEST serial clause defining LAYER {32a} PACK. {LAYER :: new DECSETY LABSETY.}

{Example
a) BEGIN x := 1; y := 2 END }
{The yield of a closed-clause is that of its constituent serial-clause, by way of pre-elaboration {2.1.4.1.c}.}

3.2. Serial clauses

{The purposes of serial-clauses are

  • the construction of new ranges of definitions, and
  • the serial composition of actions.

A serial-clause consists of a possibly empty sequence of unlabelled phrases, the last of which, if any, is a declaration, followed by a sequence of possibly labelled units. The phrases and the units are separated by go-on-tokens, viz., semicolons. Some of the units may instead be separated by completers, viz., EXITs; after a completer, the next unit must be labelled so that it can be reached. The value of the final unit, or of a unit preceding an EXIT, determines the value of the serial-clause.

For example, the following serial-clause yields true if and only if the vector a contains the integer 8:

INT n; read (n);
[1 : n] INT a; read (a);
FOR i TO n DO IF a [i] = 8 THEN GOTO success FI OD;
FALSE EXIT
success: TRUE.}

3.2.1. Syntax

a) SOID NEST serial clause defining new PROPSETY {31a , 34f, l, 35h} : SOID NEST new PROPSETY series with PROPSETY {b}. {Here PROPSETY :: DECSETY LABSETY.}

b) SOID NEST series with PROPSETY {a, b, 34c} : strong void NEST unit {d}, go on {94f} token, SOID NEST series with PROPSETY {b}; where (PROPSETY) is (DECS DECSETY LABSETY), NEST declaration of DECS {41a} , go on {94f} token, SOID NEST series with DECSETY LABSETY {b}; where (PROPSETY) is (LAB LABSETY), NEST label definition of LAB {c}, SOID NEST series with LABSETY {b}; where (PROPSETY) is (LAB LABSETY) and SOID balances SOID1 and SOID2 {e}, SOID1 NEST unit {d}, completion {94f} token, NEST label definition of LAB {c}, SOID2 NEST series with LABSETY {b}; where (PROPSETY) is (EMPTY), SOID NEST unit {d}.
c) NEST label definition of label TAG {b} : label NEST defining identifier with TAG {48a} , label {94f} token.
d) SOME unit {b, 33b, g , 34i, 35d, 46m, n, 521c, 532e, 541a, b, 543c, A34Ab, c, d} : SOME UNIT {5A , -}.
e) WHETHER SORT MOID balances SORT1 MOID1 and SORT2 MOID2 {b, 33b , 34d, h} : WHETHER SORT balances SORT1 and SORT2 {f} and MOID balances MOID1 and MOID2 {g}.
f) WHETHER SORT balances SORT1 and SORT2 {e, 522a} : where (SORT1) is (strong), WHETHER (SORT2) is (SORT) ; where (SORT2) is (strong), WHETHER (SORT1) is (SORT).
g) WHETHER MOID balances MOID1 and MOID2 {e} : where (MOID1) is (MOID2), WHETHER (MOID) is (MOID1) ; where (MOID1) is (transient MOID2), WHETHER (MOID) is (MOID1) ; where (MOID2) is (transient MOID1), WHETHER (MOID) is (MOID2).
h) *SOID unitary clause : SOID NEST unit {d}.
i) *establishing clause : SOID NEST serial clause defining LAYER {32a} ; MODE NEST enquiry clause defining LAYER {34c} .

{Examples:
b) read (x1); REAL s:=0;
     sum: FOR i TO n DO (x1[i] > 0 | s +:= x1[i] | nonpos) OD EXIT
     nonpos: print (s) •
   REAL s := 0;
     sum: FOR i TO n DO (x1[i] > 0 | s +:= x1[i] | nonpos) OD EXIT
     nonpos: print (s) •
   sum: FOR i TO n DO (x1[i] > 0 | s +:= x1[i] | nonpos) OD EXIT
     nonpos: print (s) •
   FOR i TO n DO (x1[i] > 0 | s +:= x1[i] | nonpos) OD EXIT
     nonpos: print (s) •

   print (s)
c) sum:
d) print (s) }

{Often, a series must be "balanced" {3.2.1.e}. For remarks concerning balancing, see 3.4.1 .}

3.2.2. Semantics

a) The yield of a serial-clause, in an environ E, is the yield of the elaboration of its series, or of any series elaborated "in its place" {5.4.4.2}, in the environ "established" {b} around E according to that serial-clause; it is required that the yield be not newer in scope than E.

b) The environ E "established"

  • upon an environ, E1, possibly not specified, {which determines its scope,}
  • around an environ E2 {which determines its composition},
  • according to a NOTION-defining-new-PROPSETY C, possibly absent, {which prescribes its locale,}
  • with values V1, ... , Vn, possibly absent, {which are possibly to be ascribed,}
is determined as follows:
• if E1 is not specified, then let E1 be E2;
E is newer in scope than E1 and is composed of E2 and a new locale corresponding to 'PROPSETY', if C is present, and to 'EMPTY' otherwise;
Case A: C is an establishing-clause:
For each constituent mode-definition M, if any, of C,
  • the scene composed of
    1. the actual-declarer of M, and
    2. the environ necessary for {7.2.2.c} that actual-declarer in E,
    is ascribed in E to the mode-indication of M;
For each constituent label-definition L, if any, of C,
  • the scene composed of
    1. the series of which L is a direct descendent, and
    2. the environ E,
    is ascribed in E to the label-identifier of L:
If each 'PROP' enveloped by 'PROPSETY' is some 'DYADIC TAD' or 'label TAG',
then E is said to be "nonlocal" {see 5.2.3.2.b} ;
Case B: C is a declarative, a for-part or a specification:
For i = 1 ... n, where n is the number of 'DEC's enveloped by 'PROPSETY',
• Vi is ascribed {4.8.2.a} in E to the i-th constituent defining-identifier, if any, of C and, otherwise {in the case of an invisible for-part} , to an integral-defining-indicator-with-letter-aleph;
If C is a for-part or a specification,
then E is nonlocal.
{Other cases, i.e., when C is absent:
E is local (see 5.2.3.2.b), but not further defined.}

c) The yield W of a series C is determined as follows:
If C contains a direct descendent unit which is not followed by a go-on-token, then

    W is the yield of that unit;
otherwise,
    • the declaration or the unit, if any, of C is elaborated;
    W is the yield of the series of C.
{See also 5.4.4.2.Case A .}

3.3. Collateral and parallel clauses

{Collateral-clauses allow an arbitrary merging of streams of actions. Parallel-clauses provide, moreover, levels of coordination for the synchronization {10.2.4} of that merging.
A collateral- or parallel-clause consists of a sequence of units separated by and-also-symbols (viz., ", "), and is enclosed by parentheses or by a BEGIN-END pair; a parallel-clause begins moreover with PAR.
Collateral-clauses, but not parallel-clauses, may yield stowed values composed from the yields of the constituent units.
Examples of collateral-clauses yielding stowed values:

[] INT q = (1, 4, 9, 16, 25);
STRUCT (INT price, STRING category) bike := (150, "sport").
Example of a parallel-clause which synchronizes eating and speaking:.
PROC VOID eat, speak; SEMA mouth = LEVEL 1;
   PAR BEGIN
       DO
           DOWN mouth;
           eat;
           UP mouth
       OD, 
       DO
           DOWN mouth;
           speak;
           UP mouth
       OD
   END.}

3.3.1. Syntax

a) strong void NEST collateral clause {5D , 551a} : strong void NEST joined portrait {b} PACK.
b) SOID NEST joined portrait {a, b, c, d, 34g} : where SOID balances SOID1 and SOID2 {32e} , SOID1 NEST unit {32d} , and also {94f} token, SOID2 NEST unit {32d} or alternatively SOID2 NEST joined portrait {b}.
c) strong void NEST parallel clause {5D , 551a} : parallel {94f} token, strong void NEST joined portrait {b} PACK.
d) strong ROWS of MODE NEST collateral clause {5D , 551a} : where (ROWS) is (row), strong MODE NEST joined portrait {b} PACK ; where (ROWS) is (row ROWS1), strong ROWS1 of MODE NEST joined portrait {b} PACK ; EMPTY PACK.
e) strong structured with FIELDS FIELD mode NEST collateral clause {5D , 551a} : NEST FIELDS FIELD portrait {f} PACK.
f) NEST FIELDS FIELD portrait {e, f} : NEST FIELDS portrait {f, g}, and also {94f} token, NEST FIELD portrait {g}. {FIELD :: MODE field TAG.}
g) NEST MODE field TAG portrait {f} : strong MODE NEST unit {32d} .
h) *structure display : strong structured with FIELDS FIELD mode NEST collateral clause {e}.
i) *row display : strong ROWS of MODE NEST collateral clause {d}.
j) *display : strong STOWED NEST collateral clause {d, e}.
k) *vacuum : EMPTY PACK.

{Examples:
a) (x := 1, y := 2)             
b) x := 1, y := 2
c) x := 1, y := 2 d) (1, 2) (in [] REAL (1, 2))
e) (1, 2) (in COMPL (1, 2))      
f) 1, 2
g) 1 }

{Structure-displays must contain at least two FIELD-portraits, for, otherwise, in the reach of

    MODE M = STRUCT (REF M m); M nobuo, yoneda;,
the assignation nobuo := (yoneda) would be syntactically ambiguous and could produce different effects; however, m OF nobuo := yoneda is unambiguous.
Row-displays contain zero, two or more constituent units. It is also possible to present a single value as a multiple value, e.g., [1: 1] INT v := 123, but this uses a coercion known as rowing {6.6}.}

3.3.2. Semantics

a) The elaboration of a void-collateral-clause or void-parallel-clause consists of the collateral elaboration of its constituent units and yields empty.

b) The yield W of a STOWED-collateral-clause C is determined as follows:
If the direct descendent of C is a vacuum,
then

    {'STOWED' is some 'ROWS of MODE' and} each bound pair in the descriptor of W is (1, 0) {and it has one ghost element whose value is irrelevant};
otherwise,
  • let V1, ... , Vm be the {collateral} yields of the constituent units of C;

  • Case A: 'STOWED' is some 'structured with FIELDS mode':
    • the fields of W, taken in order, are V1, ... , Vm;
    Case B: 'STOWED' is some 'row of MODE1':
    W is composed of
    1. a descriptor ( (1, m)),
    2. V1, ... , Vm;
    For i = 1 ... m,
      • the element selected by the index (i) in W is Vi;

    Case C: 'STOWED' is some 'row ROWS of MODE2':
    • it is required that the descriptors of V1, ... , Vm be identical;
    • let the descriptor of {say} V1 be ( (l1, u1), ..., (ln, un));
    • W is composed of
      1. a descriptor ( (1, m), (l1, u1), ..., (ln, un));
      2. the elements of V1, ... , Vm;

      For i = 1 ... m,
      • the element selected by an index (i, i1, ... , in) in W is that selected by (i1, ... , in) in Vi.

{Note that in [, , ]CHAR block = ("abc", "def"), the descriptor of the three-dimensional yield W will be ( (1, 2), (1, 1), (1, 3)), since the units "abc" and "def" are first rowed {6.6}, so that V1 and V2 have descriptors ( (1, 1), (1, 3)).}

3.4. Choice clauses

{Choice-clauses enable a dynamic choice to be made among different paths in a computation. The choice among the alternatives (the in-CHOICE- and the out-CHOICE-clause) is determined by the success or failure of a test on a truth value, on an integer or on a mode. The value under test is computed by an enquiry-clause before the choice is made.

A choice-using-boolean-clause (or conditional-clause) is of the form
(x > 0 | x | 0) in the "brief" style, or
IF x > 0 THEN x ELSE 0 FI in the "bold" style;
x > 0 is the enquiry-clause, THEN x is the in-CHOICE-clause and ELSE 0 is the out-CHOICE-clause; all three may have the syntactical structure of a series, because all choice-clauses are well closed. A choice-using-boolean-clause may also be reduced to
(x < 0 | x := - x) or
IF x < 0 THEN x := - x FI;
the omitted out-CHOICE-clause is then understood to be an ELSE SKIP. On the other hand, the choice can be reiterated by writing
(x > 0 | 1 + x |: x < 0 | 1 - x | 1) or
IF x > 0 THEN 1 + x ELIF x < 0 THEN 1 - x ELSE 1 FI,
and so on; this is to be understood as
(x > 0 | 1 + x | (x < 0 | 1 - x | 1)).

CASE-clauses, which define choices depending on an integer or on a mode, are different in that the in-CASE-clause is further decomposed into units. The general pattern is
(- | -, ... , - | -) or
CASE -IN-, ... , -OUT- ESAC.
The choice may also be reiterated by use of OUSE.

In a choice-using-integral-clause (or case-clause), the parts are simply units and there must be at least two of them; the choice among the units follows their textual ordering.
Example:

PROC VOID work, relax, enjoy;
CASE INT day; read (day); day
IN work, work, work, work, work, relax, enjoy
OUT print ( (day, "is not in the week"))
ESAC.
In a choice-using-UNITED-clause (or conformity-clause), which tests modes, each case-part-of-CHOICE is of the form (DECLARER identifier): unit or (DECLARER): unit. The mode specified by the declarer is compared with the mode of the value under test; the identifier, if present, is available inside the unit to access that value, with the full security of syntactical mode checking. The 'UNITED' mode provides the required freedom for the mode of the value under test; moreover, that 'UNITED' mode must contain the mode of each specification for, otherwise, the corresponding case-part-of-CHOICE could never be chosen.
Example:
MODE BOY = STRUCT (INT age, REAL weight), 
MODE GIRL = STRUCT (INT age, REAL beauty);
PROC UNION (BOY, GIRL) newborn;
CASE newborn IN
   (BOY john): print (weight OF john), 
   (GIRL mary): print (beauty OF mary)
ESAC.
}
{The flowers that bloom in the spring,
Tra la,
Have nothing to do with the case.
Mikado, W.S. Gilbert.}


{The hierarchy of ranges in conditional-clauses is illustrated by

    ------------IF------------
    |  --THEN--    --ELSE--  |
    |  |      |    |      |  |
    |  --------    --------  |
    ------------FI------------
    
and similarly for the other kinds of choice. Thus the nest and the environ of the enquiry-clause remain valid over the in-CHOICE-clause and the out-CHOICE-clause. However, no transfer back from the in- or out-CHOICE-clause into the enquiry-clause is possible, since the latter can contain no label-definitions (except within a closed-clause contained within it).}

3.4.1. Syntax

A) CHOICE :: choice using boolean ; CASE.
B) CASE :: choice using integral ; choice using UNITED.
a) SOID NEST1 CHOICE clause {5D , 551a, A341h, A349a} : CHOICE STYLE start {91a , -}, SOID NEST1 chooser CHOICE STYLE clause {b}, CHOICE STYLE finish {91e , -}.
b) SOID NEST1 chooser choice using MODE STYLE clause {a, l} : MODE NEST1 enquiry clause defining LAYER2 {c, -}, SOID NEST1 LAYER2 alternate choice using MODE STYLE clause {d}.
c) MODE NEST1 enquiry clause defining new DECSETY2 {b, 35g} : meek MODE NEST1 new DECSETY2 series with DECSETY2 {32b} .
d) SOID NEST2 alternate CHOICE STYLE clause {b} : SOID NEST2 in CHOICE STYLE clause {e}; where SOID balances SOID1 and SOID2 {32e} , SOID1 NEST2 in CHOICE STYLE clause {e}, SOID2 NEST2 out CHOICE STYLE clause {l}.
e) SOID NEST2 in CHOICE STYLE clause {d} : CHOICE STYLE in {91b , -}, SOID NEST2 in part of CHOICE {f, g, h}.
f) SOID NEST2 in part of choice using boolean {e} : SOID NEST2 serial clause defining LAYER3 {32a} .
g) SOID NEST2 in part of choice using integral {e} : SOID NEST2 joined portrait {33b} .
h) SOID NEST2 in part of choice using UNITED {e, h} : SOID NEST2 case part of choice using UNITED {i}; where SOID balances SOID1 and SOID2 {32e} , SOID1 NEST2 case part of choice using UNITED {i}, and also {94f} token, SOID2 NEST2 in part of choice using UNITED {h}.
i) SOID NEST2 case part of choice using UNITED {h} : MOID NEST2 LAYER3 specification defining LAYER3 {j, k, -}, where MOID unites to UNITED {64b} , SOID NEST2 LAYER3 unit {32d} .
{HereLAYER :: new MODE TAG ; new EMPTY.}
j) MODE NEST3 specification defining new MODE TAG3 {i} : NEST3 declarative defining new MODE TAG3 {541e} brief pack, colon {94f} token.
k) MOID NEST3 specification defining new EMPTY {i} : formal MOID NEST3 declarer {46b} brief pack, colon {94f} token.
l) SOID NEST2 out CHOICE STYLE clause {d} : CHOICE STYLE out {91d , -}, SOID NEST2 serial clause defining LAYER3 {32a} ; CHOICE STYLE again {91c , -}, SOID NEST2 chooser CHOICE2 STYLE clause {b}, where CHOICE2 may follow CHOICE {m}.
m) WHETHER choice using MODE2 may follow choice using MODE1 {l} : where (MODE1) is (MOOD), WHETHER (MODE2) is (MODE1) ; where (MODE1) begins with (union of), WHETHER (MODE2) begins with (union of).
n) *SOME choice clause : SOME CHOICE clause {a}.
o) *SOME conditional clause : SOME choice using boolean clause {a}.
p) *SOME case clause : SOME choice using integral clause {a}.
q) *SOME conformity clause : SOME choice using UNITED clause {a}.

{Examples:
a) (x > 0 | x | 0) •
        CASE i IN princeton, grenoble OUT finish ESAC •
        CASE uir IN (INT i): print (i), (REAL): print ("no") ESAC
b) x > 0 | x | 0
c) x > 0 • i • uir
d) | x • |x | 0
e) | x •
       IN princeton, grenoble •
       IN (INT i): print (i), (REAL): print ("no")
f) x
g) princeton, grenoble
h) (INT i): print (i), (REAL): print ("no")
i) (INT i): print (i)
j) (INT i):
k) (REAL):
l) OUT finish • |: x < 0 | -x | 0 }
{I would to God they would either conform,
or be more wise, and not be catched!
Diary. 7 Aug. 1664, Samuel Pepys.}

{Rule d illustrates why 'SORT MOID's should be "balanced". If an alternate-CHOICE-clause is, say, firm, then at least its in-CHOICE-clause or its out-CHOICE-clause must be firm, while the other may be strong. For example, in (p | x | SKIP) + (p | SKIP | y), the conditional-clause (p | x | SKIP) is balanced by making | x firm and | SKIP strong whereas (p | SKIP | y) is balanced by making | SKIP strong and | y firm. The counterexample (p | SKIP | SKIP) + y illustrates that not both may be strong, for otherwise the operator + could not be identified.}

3.4.2. Semantics

a) The yield W of a chooser-CHOICE-clause C, in an environ E1, is determined as follows:
• let E2 be the environ established {3.2.2.b} around E1 according to the enquiry-clause of C;
• let V be the yield, in E2, of that enquiry-clause;
W is the yield of the scene "chosen" {b} by V from C in E2; it is required that W be not newer in scope than E1.

b) The scene S "chosen" by a value V from a MOID-chooser-CHOICE-clause C, in an environ E2, is determined as follows:

Case A: 'CHOICE' is 'choice using boolean' and V is true:

    S is the constituent in-CHOICE-clause of C, in E2;
Case B: 'CHOICE' is 'choice using integral' and 1 ≤V ≤n, where n is the number of constituent units of the constituent in-part-of-CHOICE of C:
    S is the V-th such unit, in E2;
Case C: 'CHOICE' is some 'choice using UNITED' and V is acceptable to {2.1.3.6.d} the 'MOID2' of some constituent MOID2-specification D of C {; if there exists more than one such constituent specification, it is not defined which one is chosen as D} ;
    S is the unit following that D, in an environ established {nonlocally {3.2.2.b}} around E2, according to D, with V;
Other Cases {when the enquiry-clause has been unsuccessful} :
    If C contains a constituent out-CHOICE-clause O,
    then S is O in E2;
    otherwise, S is a MOID-skip in E2.

3.5. Loop clauses

{Loop-clauses are used for repeating dynamically one same sequence of instructions. The number of repetitions is controlled by a finite sequence of equidistant integers, by a condition to be tested each time, or by both.
Example 1:

INT fac := 1;
FOR i FROM n BY -1 TO 1
DO fac ×:= i OD.
Example 2:
INT a, b; read ( (a, b)) PR ASSERT a ≥ 0 & b > 0 PR;
INT q := 0, r := a;
WHILE r ≥ b PR ASSERT a = b * q + r & 0 ≤ r PR
DO (q +:= 1, r -:= b) OD
PR ASSERT a = b × q + r & 0 ≤ r & r < b PR
(see 9.2 for an explanation of the pragmats).

The controlled identifier, e.g., i in Example 1, is defined over the repeating-part. Definitions introduced in the while-part are also valid over the do-part.
If the controlled identifier is not applied in the repeating-part, then the for-part may be omitted. A from-part FROM 1 may be omitted; similarly, BY 1 may be omitted. The to-part may be omitted if no test on the final value of the control-integer is required. A while-part WHILE TRUE may be omitted. For example,

FOR i FROM 1 BY 1 TO n WHILE TRUE DO print ("a") OD
may be written
TO n DO print ("a") OD
.

The hierarchy of ranges is illustrated by:

          ----
    1 FOR |  | FROM BY TO
    -------  ------------
    |   2 -----WHILE--- |
    |     |   3--DO-- | |
    |     |    |    | | |
    |     |    --OD-- | |
    |     ------------- |
    ---------------------
    

}

3.5.1. Syntax

A) FROBYT :: from ; by ; to.
a) strong void NEST1 loop clause {5D , 551a} : NEST1 STYLE for part defining new integral TAG2 {b}, NEST1 STYLE intervals {c}, NEST1 STYLE repeating part with integral TAG2 {e}.
b) NEST1 STYLE for part defining new integral TAG2 {a} : STYLE for {94g , -} token, integral NEST1 new integral TAG2 defining identifier with TAG2 {48a} ; where (TAG2) is (letter aleph), EMPTY.
c) NEST1 STYLE intervals {a} : NEST1 STYLE from part {d} option, NEST1 STYLE by part {d} option, NEST1 STYLE to part {d} option.
d) NEST1 STYLE FROBYT part {c} : STYLE FROBYT {94g , -} token, meek integral NEST1 unit {32d} .
e) NEST1 STYLE repeating part with DEC2 {a} : NEST1 new DEC2 STYLE while do part {f}; NEST1 new DEC2 STYLE do part {h}.
f) NEST2 STYLE while do part {e} : NEST2 STYLE while part defining LAYER3 {g}, NEST2 LAYER3 STYLE do part {h}.
g) NEST2 STYLE while part defining LAYER3 {f} : STYLE while {94g , -} token, boolean NEST2 enquiry clause defining LAYER3 {34c , -}.
h) NEST3 STYLE do part {e, f} : STYLE do {94g , -} token, strong void NEST3 serial clause defining LAYER4 {32a} , STYLE od {94g , -} token.

{Examples:
a) FOR i WHILE i < n DO task1 OD • TO n DO task1; task2 OD
b) FOR i
c) FROM -5 TO +5
d) FROM -5
e) WHILE i < n DO task1 OD • DO task1; task2 OD
f) WHILE i < n DO task 1; task2 OD
g) WHILE i < n
h) DO task1; task2 OD }

3.5.2. Semantics

A loop-clause C, in an environ E1, is elaborated in the following Steps:
Step 1: All the constituent FROBYT-parts, if any, of C are elaborated collaterally in E1;

    • let f be the yield of the constituent from-part, if any, of C, and be 1 otherwise;
    • let b be the yield of the constituent by-part, if any, of C, and be 1 otherwise;
    • let t be the yield of the constituent to-part, if any, of C, and be absent otherwise;
    • let E2 be the environ established {nonlocally {3.2.2.b}} around E1, according to the for-part-defining-new-integral-TAG2 of C, and with the integer f;
Step 2: Let i be the integer accessed {2.1.2.c} by 'integral TAG2' inside the locale of E2;
    If t is not absent,
    then
      If b > 0 and i > t or if b < 0 and i < t,
      then C in E1 {is completed and} yields empty;
    {otherwise, Step 3 is taken;}
Step 3: Let an environ E3 and a truth value w be determined as follows:
    Case A: C does not contain a constituent while-part:
      E3 is E2;
      w is true;
    Case B: C contains a constituent while-part P:
      E3 is established {perhaps nonlocally {3.2.2.b}} around E2 according to the enquiry-clause of P;
      w is the yield in E3 of that enquiry-clause;
Step 4: If w is true, then
    • the constituent do-part of C is elaborated in E3;
    'integral TAG2' is made to access i + b inside the locale of E2;
      [[Note the possibility of overflow even in case TAG2 and intervals are empty]]
    • Step 2 is taken again; otherwise,
    C in E1 {is completed and} yields empty.

{The loop-clause

FOR i FROM u1 BY u2 TO u3 WHILE condition DO action OD
is thus equivalent to the following void-closed-clause:
BEGIN INT f:= u1, INT b = u2, t = u3;
   step2:
      IF (b > 0 & f ≤ t) OR (b < 0 & f ≥ t) OR b = 0
      THEN INT i = f;
         IF condition
         THEN action; f +:= b; GO TO step2
         FI
      FI
END
.

This equivalence might not hold, of course, if the loop-clause contains local-generators, or if some of the operators above do not identify those in the standard environment {10}.}


«Table of contents»

4. Declarations, declarers and indicators

{Declarations serve

  • to announce new indicators, e.g., identifiers,
  • to define their modes or priorities, and
  • to ascribe values to those indicators and to initialize variables.}

4.1. Declarations

4.1.1. Syntax

A) COMMON :: mode ; priority ; MODINE identity ; reference to MODINE variable ; MODINE operation ; PARAMETER ; MODE FIELDS. {MODINE :: MODE ; routine.}
a) NEST declaration of DECS {a, 32b} : NEST COMMON declaration of DECS {42a , 43a, 44a, e, 45a, -}; where (DECS) is (DECS1 DECS2), NEST COMMON declaration of DECS1 {42a , 43a, 44a, e, 45a, -}, and also {94f} token, NEST declaration of DECS2 {a}.
b) NEST COMMON joined definition of PROPS PROP {b, 42a , 43a, 44a, e, 45a, 46e, 541e} : NEST COMMON joined definition of PROPS {b, c}, and also {94f} token, NEST COMMON joined definition of PROP {c}.
c) NEST COMMON joined definition of PROP {b, 42a , 43a, 44a, e, 45a, 46e, 541e} : NEST COMMON definition of PROP {42b , 43b, 44c, f, 45c, 46f, 541f, -}.
d) *definition of PROP : NEST COMMON definition of PROP {42b , 43b, 44c, f, 45c, 46f, 541f} ; NEST label definition of PROP {32c} .

{Examples:
a) MODE R = REF REAL, S = CHAR • PRIO OR = 2, AND = 3 • INT m =4096 •
      REAL x, y •
      OP OR = (BOOL a, b) BOOL : (a | TRUE | b)
b) R = REF REAL, S = CHAR • OR = 2, AND = 3 • m = 4096 • x, y • OR = (BOOL a, b) BOOL : (a | TRUE | b)
c) R = REF REAL • OR = 2 • m = 4096 • x • OR = (BOOL a, b) BOOL : (a | TRUE | b) }

4.1.2. Semantics

The elaboration of a declaration consists of the collateral elaboration of its COMMON-declaration and of its declaration, if any. {Thus, all the COMMON-declarations separated by and-also-tokens are elaborated collaterally.}

4.2. Mode declarations

{Mode-declarations provide the defining-mode-indications, which act as abbreviations for declarers constructed from the more primitive ones, or from other declarers, or even from themselves.
for example,
MODE ARRAY = [m, n] REAL, and
MODE BOOK = STRUCT (STRING text, REF BOOK next)
In the latter example, the applied-mode-indication BOOK is not only a convenient abbreviation, but is essential to the declaration.}

4.2.1. Syntax

a) NEST mode declaration of DECS {41a} : mode {94d} token, NEST mode joined definition of DECS {41b, c} .
b) NEST mode definition of MOID TALLY TAB {41c} : where (TAB) is (bold TAG) or (NEST) is (new LAYER), MOID TALLY NEST defining mode indication with TAB {48a} , is defined as {94d} token, actual MOID TALLY NEST declarer {c}.
c) actual MOID TALLY1 NEST declarer {b} : where (TALLY1) is (i), actual MOID NEST declarator {46c, d, g, h, o, s , -}; where (TALLY1) is (TALLY2 i), MOID TALLY2 NEST applied mode indication with TAB2 {48b} .

{Examples:
a) MODE R = REF REAL, S = CHAR
b) R = REF REAL
c) REF REAL • CHAR }

{The use of 'TALLY' excludes circular chains of mode-definitions such as MODE A = B, B = A.

Defining-mode-indications-with-SIZETY-STANDARD may be declared only in the standard-prelude, where the nest is of the form "new LAYER" {10.1.1.b}.}

4.2.2. Semantics

The elaboration of a mode-declaration {involves no action, yields no value and} is completed.

4.3. Priority declarations

{Priority-declarations are used to specify the priority of operators. Priorities from 1 to 9 are available.
Since monadic-operators have effectively only one priority-level, which is higher than that of all dyadic-operators, monadic-operators do not require priority-declarations.}

4.3.1. Syntax

a) NEST priority declaration of DECS {41a} : priority {94d} token, NEST priority joined definition of DECS {41b, c} .
b) NEST priority definition of priority PRIO TAD {41c} : priority PRIO NEST defining operator with TAD {48a} , is defined as {94d} token, DIGIT {94b} token, where DIGIT counts PRIO {c, d}.
c) WHETHER DIGIT1 counts PRIO i {b, c} : WHETHER DIGIT2 counts PRIO {c, d}, where (digit one digit two digit three digit four digit five digit six digit seven digit eight digit nine) contains (DIGIT2 DIGIT1).
d) WHETHER digit one counts i {b, c} : WHETHER true.

{Examples:
a) PRIO OR 2, AND = 3
b) OR = 2 }

4.3.2. Semantics

The elaboration of a priority-declaration {involves no action, yields no value and} is completed.

4.4. Identifier declarations

{Identifier-declarations provide MODE-defining-identifiers, by means of either identity-definitions or variable-definitions.

Examples:
REAL pi = 3.1416 • REAL scan := 0.05 .
The latter example, which is a variable-declaration, may be considered as an equivalent form of the identity-declaration
REF REAL scan = LOC REAL := 0.05.
The elaboration of identifier-declarations causes values to be ascribed to their identifiers; in the examples given above, 3.1416 is ascribed to pi and a new local name which refers to 0.05 is ascribed to scan.}

4.4.1. Syntax

A) MODINE :: MODE ; routine.
B) LEAP :: local ; heap ; primal.
a) NEST MODINE identity declaration of DECS {41a} : formal MODINE NEST declarer {b, 46b} , NEST MODINE identity joined definition of DECS {41b, c} .
b) VICTAL routine NEST declarer {a, 523b} : procedure {94d} token.
c) NEST MODINE identity definition of MODE TAG {41c} : MODE NEST defining identifier with TAG {48a} , is defined as {94d} token, MODE NEST source for MODINE {d}.
d) MODE NEST source for MODINE {c, f, 45c} : where (MODINE) is (MODE), MODE NEST source {521c} ; where (MODINE) is (routine), MODE NEST routine text {541a, b , -}.
e) NEST reference to MODINE variable declaration of DECS {41a} : reference to MODINE NEST LEAP sample generator {523b} , NEST reference to MODINE variable joined definition of DECS {41b, c} .
f) NEST reference to MODINE variable definition of reference to MODE TAG {41c} : reference to MODE NEST defining identifier with TAG {48a} , becomes {94c} token, MODE NEST source for MODINE {d}; where (MODINE) is (MODE), reference to MODE NEST defining identifier with TAG {48a} .
g) *identifier declaration : NEST MODINE identity declaration of DECS {a}; NEST reference to MODINE variable declaration of DECS {e}.

{Examples:
a) INT m = 4096 • PROC r10 = REAL: random × 10
b) PROC
c) m = 4096
d) 4096 • REAL: random × 10
e) REAL x, y • PROC pp := REAL: random × 10
f) pp := REAL: random × 10 • x }

4.4.2. Semantics

a) An identity-declaration D is elaborated as follows:
• the constituent sources-for-MODINE of D are elaborated collaterally;
For each constituent identity-definition D1 of D,

  • the yield V of the source-for-MODINE of D1 is ascribed {4.8.2.a} to the defining-identifier of D1.

b) A variable-declaration D is elaborated as follows:

• the sample-generator {5.2.3.1.b} G of D and all the sources-for-MODINE, if any, of the constituent variable-definitions of D are elaborated collaterally;
For each constituent variable-definition-of-reference-to-MODE-TAG D1 of D,

    • let W1 be a "variant" {c}, for 'MODE', of the value referred to by the yield N of G;
    • let N1 be a newly created name equal in scope to N and referring to W1;
    • if N1 is a stowed name {2.1.3.2.b}, then N1 is endowed with subnames {2.1.3.3.e , 2.1.3.4.g};
    N1 is ascribed {4.8.2.a} to the defining-identifier of D1;
    • the yield of the source-for-MODINE, if any, of D1 is assigned {5.2.1.2.b} to N1.

{An actual-declarer which is common to a number of variable-definitions is elaborated only once. For example, the elaboration of
INT m := 10; [1 : m +:= 1] INT p, q; print (m)
causes 11 to be printed, and not 12; moreover, two new local names referring to multiple values with descriptor ( (1, 11)), and undefined elements, are ascribed to p and to q.}

c) A "variant" of a value V, for a mode M, is a value W acceptable to {2.1.3.6.d} M, and determined as follows:
Case A: M is some 'structured with FIELDS mode':

    For each 'MODE field TAG' enveloped by 'FIELDS',
    • the field selected by 'TAG' in W is a variant, for 'MODE', of the field selected by 'TAG' in V;
Case B: M is some 'FLEXETY ROWS of MODE1':
  • the descriptor of W is that of V;
  • each element of W is a variant, for 'MODE1', of some element of V;
Other Cases:
  • W is any value acceptable to M.

d) The yield of an actual-routine-declarer is some routine {whose mode is of no relevance}.

4.5. Operation declarations

{Operation-declarations provide defining-operators.
Example:
OP MC = (REAL a, b) REAL: (3 × a < b | a | b ).
Unlike the case with, e.g., identifier-declarations, more than one operation-declaration involving the same TAO-token may occur in the same reach; e.g., the previous example may very well be in the same reach as
OP MC = (COMPL carthy, john) COMPL: (random < .5 | carthy | john);
the operator MC is then said to be "overloaded".}

4.5.1. Syntax

A) PRAM :: DUO ; MONO.
B) TAO :: TAD ; TAM.
a) NEST MODINE operation declaration of DECS {41a} : operator {94d} token, formal MODINE NEST plan {b, 46p, -}, NEST MODINE operation joined definition of DECS {41b, c} .
b) formal routine NEST plan {a} : EMPTY.
c) NEST MODINE operation definition of PRAM TAO {41c} : PRAM NEST defining operator with TAO {48a} , is defined as {94d} token, PRAM NEST source for MODINE {44d} .

{Examples:
a) OP OR = (BOOL a, b) BOOL: (a | TRUE | b)
c) OR = (BOOL a, b) BOOL: (a | TRUE | b) }

4.5.2. Semantics

a) The elaboration of an operation-declaration consists of the collateral elaboration of its constituent operation-definitions.

b) An operation-definition is elaborated by ascribing {4.8.2.a} the routine yielded by its source-for-MODINE to its defining-operator.

4.6. Declarers

{Declarers specify modes. A declarer is either a declarator, which explicitly constructs a mode, or an applied-mode-indication, which stands for some declarator by way of a mode-declaration. Declarators are built from VOID, INT, REAL, BOOL and CHAR {10.2.2}, with the assistance of other symbols such as REF, STRUCT, [], PROC, and UNION. For example, PROC (REAL)BOOL specifies the mode 'procedure with real parameter yielding boolean'.

Actual-declarers, used typically in generators, require the presence of bounds. Formal-declarers, used typically in formal-parameters and casts, are without bounds. The declarer following a ref is always 'virtual'; it may then specify a 'flexible ROWS of MODE', because flexibility is a property of names. Since actual-declarers follow an implicit 'reference to' in generators, they may also specify 'flexible ROWS of MODE'.}

4.6.1. Syntax

A) VICTAL :: VIRACT ; formal.
B) VIRACT :: virtual ; actual.
C) MOIDS :: MOID ; MOIDS MOID.
a) VIRACT MOID NEST declarer {c, e, g, h, 523a, b} : VIRACT MOID NEST declarator {c, d, g, h, o, s, -}; MOID TALLY NEST applied mode indication with TAB {48b , -}.
b) formal MOID NEST declarer {e, h, p, r, u, 34k , 44a, 541a, b, e, 551a} : where MOID deflexes to MOID {47a, b, c , -}, formal MOID NEST declarator {c, d, h, o, s, -}; MOID1 TALLY NEST applied mode indication with TAB {48b , -}, where MOID1 deflexes to MOID {47a, b, c , -}.
c) VICTAL reference to MODE NEST declarator {a, b, 42c} : reference to {94d} token, virtual MODE NEST declarer {a}.
d) VICTAL structured with FIELDS mode NEST declarator {a, b, 42c} : structure {94d} token, VICTAL FIELDS NEST portrayer of FIELDS {e} brief pack.
e) VICTAL FIELDS NEST portrayer of FIELDS1 {d, e} : VICTAL MODE NEST declarer {a, b}, NEST MODE FIELDS joined definition of FIELDS1 {41b, c} ; where (FIELDS1) is (FIELDS2 FIELDS3), VICTAL MODE NEST declarer {a, b}, NEST MODE FIELDS joined definition of FIELDS2 {41b, c} , and also {94f} token, VICTAL FIELDS NEST portrayer of FIELDS3 {e}.
f) NEST MODE FIELDS definition of MODE field TAG {41c} : MODE field FIELDS defining field selector with TAG {48c} .
g) VIRACT flexible ROWS of MODE NEST declarator {a, 42c} : flexible {94d} token, VIRACT ROWS of MODE NEST declarer {a}.
h) VICTAL ROWS of MODE NEST declarator {a, b, 42c} : VICTAL ROWS NEST rower {i, j, k, l} STYLE bracket, VICTAL MODE NEST declarer {a, b}.
i) VICTAL row ROWS NEST rower {h, i} : VICTAL row NEST rower {j, k, l}, and also {94f} token, VICTAL ROWS NEST rower {i, j, k, l}.
j) actual row NEST rower {h, i} : NEST lower bound {m}, up to {94f} token, NEST upper bound {n}; NEST upper bound {n}.
k) virtual row NEST rower {h, i} : up to {94f} token option.
l) formal row NEST rower {h, i} : up to {94f} token option.
m) NEST lower bound {j, 532f, g} : meek integral NEST unit {32d} .
n) NEST upper bound {j, 532f} : meek integral NEST unit {32d} .
o) VICTAL PROCEDURE NEST declarator {a, b, 42c} : procedure {94d} token, formal PROCEDURE NEST plan {p}.
p) formal procedure PARAMETY yielding MOID NEST plan {o, 45a} : where (PARAMETY) is (EMPTY), formal MOID NEST declarer {b}; where (PARAMETY) is (with PARAMETERS), PARAMETERS NEST joined declarer {q, r} brief pack, formal MOID NEST declarer {b}.
q) PARAMETERS PARAMETER NEST joined declarer {p, q} : PARAMETERS NEST joined declarer {q, r}, and also {94f} token, PARAMETER NEST joined declarer {r}.
r) MODE parameter NEST joined declarer {p, q} : formal MODE NEST declarer {b}.
s) VICTAL union of MOODS1 MOOD1 mode NEST declarator {a, b, 42c} : unless EMPTY with MOODS1 MOOD1 incestuous {47f} , union of {94d} token, MOIDS NEST joined declarer {t, u} brief pack, where MOIDS ravels to MOODS2 {47g} and safe MOODS1 MOOD1 subset of safe MOODS2 {73l} and safe MOODS2 subset of safe MOODS1 MOOD1 {73l, m} .
t) MOIDS MOID NEST joined declarer {s, t} : MOIDS NEST joined declarer {t, u}, and also {94f} token, MOID NEST joined declarer {u}.
u) MOID NEST joined declarer {s, t} : formal MOID NEST declarer {b}.

{Examples:
a) [1 : n] REAL • PERSON 
b) [] REAL • STRING
c) REF REAL
d) STRUCT (INT age, REF PERSON father, son)
e) REF PERSON father, son • INT age, REF PERSON father, son
f) age 
g) FLEX [1 : n] REAL
h) [1 : m, 1 : n] REAL 
i) 1 : m, 1 : n
j) 1 : n 
k) :
l) :                                      
m) 1
n) n 
o) PROC (BOOL, BOOL) BOOL
p) (BOOL, BOOL) BOOL q) BOOL, BOOL
r) BOOL s) UNION (INT, CHAR)
t) INT, CHAR u) INT }

{For actual-MOID-TALLY-declarers, see 4.2.1.c ; for actual-routine-declarers, see 4.4.1.b .
There are no declarers specifying modes such as 'union of integral union of integral real mode mode' or 'union of integral real integral mode'. The declarers UNION (INT, UNION (INT, REAL)) and UNION (INT, REAL, INT) may indeed be written, but in both cases the mode specified is 'union of integral real mode' (which can as well be spelled 'union of real integral mode').}

4.6.2. Semantics

a) The yield W of an actual-MODE-declarer D, in an environ E, is determined as follows:
If 'MODE' is some 'STOWED',
then

  • let D1 in E1 be "developed" {c} from D in E;
  • W is the yield of {the declarator} D1 in an environ established {locally, see 3.2.2.b} upon E and around E1;
otherwise,
  • W is any value {acceptable to 'MODE'} .

b) The yield W of an actual-STOWED-declarator D is determined as follows:
Case A: 'STOWED' is some 'structured with FIELDS mode':

  • the constituent declarers of D are elaborated collaterally;
  • each field of W is a variant {4.4.2.c}
  1. of the yield of the last constituent MODE-declarer of D occurring before the constituent defining-field-selector of D selecting {2.1.5.g} that field,
  2. for that 'MODE';

Case B: 'STOWED' is some 'ROWS of MODE':
  • all the constituent lower-bounds and upper-bounds of D and the declarer D1 of D are elaborated collaterally;
    For i = 1 ... n, where n is the number of 'row's contained in 'ROWS',
    • let li be the yield of the lower-bound, if any, of the i-th constituent row-rower of D, and be 1 otherwise;
    • let ui be the yield of the upper-bound of that row-rower;
  • W is composed of
  1. a descriptor ( (l1, u1), ..., (ln, un)),
  2. variants of the yield of D1, for 'MODE';

Case C: 'STOWED' is some 'flexible ROWS of MODE':
  • W is the yield of the declarer of D.

c) The scene S "developed from" an actual-STOWED-declarer D in an environ E is determined as follows:
If the visible direct descendent D1 of D is a mode-indication,
then

  • S is the scene developed from that yielded by D1 in E;
otherwise {D1 is a declarator} ,
  • S is composed of D1 and E.

d) A given MOID-declarer "specifies" the mode 'MOID'.

4.7. Relationships between modes

{Some modes must be deflexed because the mode of a value may not be flexible {2.1.3.6.b}. Incestuous unions must be prevented in order to avoid ambiguities. A set of 'UNITED's and 'MOODS's may be ravelled by replacing all those 'UNITED's by their component 'MOODS's.}

4.7.1. Syntax

A) NONSTOWED :: PLAIN ; REF to MODE ; PROCEDURE ; UNITED ; void.
B) MOODSETY :: MOODS ; EMPTY.
C) MOIDSETY :: MOIDS ; EMPTY.
a) WHETHER NONSTOWED deflexes to NONSTOWED {b, e, 46b , 521c, 62a, 71n} : WHETHER true.
b) WHETHER FLEXETY ROWS of MODE1 deflexes to ROWS of MODE2 {b, e, 46b , 521c, 62a, 71n} : WHETHER MODE1 deflexes to MODE2 {a, b, c, -}.
c) WHETHER structured with FIELDS1 mode deflexes to structured with FIELDS2 mode {b, e, 46b , 521c, 62a, 71n} : WHETHER FIELDS1 deflexes to FIELDS2 {d, e, -}.
d) WHETHER FIELDS1 FIELD1 deflexes to FIELDS2 FIELD2 {c, d} : WHETHER FIELDS1 deflexes to FIELDS2 {d, e, -} and FIELD1 deflexes to FIELD2 {e, -}.
e) WHETHER MODE1 field TAG deflexes to MODE2 field TAG {c, d} : WHETHER MODE1 deflexes to MODE2 {a, b, c, -}.
f) WHETHER MOODSETY1 with MOODSETY2 incestuous {f, 46s} : where (MOODSETY2) is (MOOD MOODSETY3), WHETHER MOODSETY1 MOOD with MOODSETY3 incestuous {f} or MOOD is firm union of MOODSETY1 MOODSETY3 mode {71m} ; where (MOODSETY2) is (EMPTY), WHETHER false.
g) WHETHER MOIDS ravels to MOODS {g, 46s} : where (MOIDS) is (MOODS), WHETHER true ; where (MOIDS) is (MOODSETY union of MOODS1 mode MOIDSETY), WHETHER MOODSETY MOODS1 MOIDSETY ravels to MOODS {g}.

{A component mode of a union may not be firmly coerced to one of the other component modes or to the union of those others (rule f) for, otherwise, ambiguities could arise. For example,

UNION (REF INT, INT) (LOC INT)
is ambiguous in that dereferencing may or may not occur before the uniting. Similarly,
MODE SZP = UNION (SZEREDI, PETER);
UNION (REF SZP, SZP) (LOC SZP)
is ambiguous. Note that, because of ravelling (rule g), the mode specified by the declarer of the cast is more closely suggested by UNION (REF SZP, SZEREDI, PETER).}

4.8. Indicators and field selectors

4.8.1. Syntax

A) INDICATOR :: identifier ; mode indication ; operator.
B) DEFIED :: defining ; applied.
C) PROPSETY :: PROPS ; EMPTY.
D) PROPS :: PROP ; PROPS PROP.
E) PROP :: DEC ; LAB ; FIELD.
F) QUALITY :: MODE ; MOID TALLY ; DYADIC ; label ; MODE field.
G) TAX :: TAG ; TAB ; TAD ; TAM.
a) QUALITY NEST new PROPSETY1 QUALITY TAX PROPSETY2 defining INDICATOR with TAX {32c , 35b, 42b, 43b, 44c, f, 45c, 541f} : where QUALITY TAX independent PROPSETY1 PROPSETY2 {71a, b, c} , TAX {942A, D, F, K} token.
b) QUALITY NEST applied INDICATOR with TAX {42c , 46a, b, 5D, 542a, b, 544a} : where QUALITY TAX identified in NEST {72a} , TAX {942A, D, F, K} token.
c) MODE field PROPSETY1 MODE field TAG PROPSETY2 defining field selector with TAG {46f} : where MODE field TAG independent PROPSETY1 PROPSETY2 {71a, b, c} , TAG {942A} token.
d) MODE field FIELDS applied field selector with TAG {531a} : where MODE field TAG resides in FIELDS {72b, c , -}, TAG {942A} token.
e) *QUALITY NEST DEFIED indicator with TAX : QUALITY NEST DEFIED INDICATOR with TAX {a, b}.
f) *MODE DEFIED field selector with TAG : MODE field FIELDS DEFIED field selector with TAG {c, d}.

{Examples:
a) x (in REAL x, y)
b) x (in x + y)
c) next (see 1.1.2)
d) next (in next OF draft) }

4.8.2. Semantics

a) When a value or a scene V is "ascribed" to a QUALITY-defining-indicator-with-TAX, in an environ E, then 'QUALITY TAX' is made to access V inside the locale of E {2.1.2.c}.

b) The yield W of a QUALITY-applied-indicator-with-TAX I in an environ E composed of an environ E1 and a locale L is determined as follows:


If L corresponds to a 'DECSETY LABSETY' which envelops {1.1.4.1.c} that 'QUALITY TAX',
then
    W is the value or scene, if any, accessed inside L by 'QUALITY TAX' and, otherwise, is undefined;
otherwise, W is the yield of I in E1.

{Consider the following closed-clause, which contains another one:

BEGIN CO range 1 CO
   INT i = 421, INT a := 5, PROC p = VOID: print (a);
   BEGIN CO range 2 CO
      REAL a; a := i; p
   END
END.
By the time a := i is encountered during the elaboration, two new environs have been created, one for each range. The defining-identifier i is first sought in the newer one, E2, is not found there, and then is sought and found in the older one, E1. The locale of E1 corresponds to 'integral letter i reference to integral letter a procedure yielding void letter p'. The yield of the applied-identifier i is therefore the value 421 which has been ascribed {a} to 'integral letter i' inside the locale of E1. The yield of a, in a := i, however, is found from the locale of E2.

When p is called {5.4.3.2.b}, its unit is elaborated in an environ E3 established around E1 but upon E2 {3.2.2.b}. This means that, for scope purposes, E3 is newer than E2, but the component environ of E3 is E1. When a comes to be printed, it is the yield 5 of the reference-to-integral-identifier a declared in the outer range that is obtained.

Thus, the meaning of an indicator applied but not defined within a routine is determined by the context in which the routine was created, rather than that in which it is called.}


«Table of contents»

5. Units

{Units are used to program the more primitive actions or to put into one single piece the larger constructs of Chapter 3.
NOTION-coercees are the results of coercion (Chapter 6), but hips are not; in the case of ENCLOSED-clauses, any coercions needed are performed inside them.
The syntax below implies, for example, that text OF draft + "the end" is parsed as (text OF draft) + "the end" since a selection is a 'SECONDARY' whereas a formula is a 'TERTIARY'.}

5.1. Syntax

A) UNIT {32d} :: assignation {521a} coercee ; identity relation {522a} coercee ; routine text {541a, b} coercee ; jump {544a} ; skip {552a} ; TERTIARY {B}.
B) TERTIARY {A, 521b , 522a} :: ADIC formula {542a, b} coercee ; nihil {524a} ; SECONDARY {C}.
C) SECONDARY {B, 531a , 542c} :: LEAP generator {523a} coercee ; selection {531a} coercee ; PRIMARY {D}.
D) PRIMARY {C, 532a , 543a} :: slice {532a} coercee ; call {543a} coercee ; cast {551a} coercee ; denoter {80a} coercee ; format text {A341a} coercee ; applied identifier with TAG {48b} coercee ; ENCLOSED clause {31a , 33a, c, d, e, 34a, 35a} .

{The hyper-rules for 'SORT MOID FORM coercee' are given in 6.1.1.a, b, c, d and e, the entry rules of the coercion syntax. When the coercion syntax is invoked for some 'SORT MOID FORM coercee', it will eventually return to a rule in this chapter for some 'MOID1 FORM' (blind alleys apart). It is the cross-reference to that rule that is given in the metaproduction rules above. No other visible descendent has been produced in the meantime; the coercion syntax merely transforms 'MOID' into 'MOID1' for semantical purposes.}

a) *SOME hip : SOME jump {544a} ; SOME skip {552a} ; SOME nihil {524a} . {The mode of a hip is always that required, a posteriori, by its context, and its yield is acceptable to that mode. Since any mode is so easily accommodated, no coercion is permitted.}

5.2. Units associated with names

{Names may be assigned to {5.2.1}, compared with other names {5.2.2} and created {5.2.3}.}

5.2.1. Assignations

{In assignations, a value is "assigned", to a name. E.g., in x := 3.14, the real number yielded by the source 3.14 is assigned to the name yielded by the destination x.}

5.2.1.1. Syntax

a) REF to MODE NEST assignation {5A} : REF to MODE NEST destination {b}, becomes {94c} token, MODE NEST source {c}.
b) REF to MODE NEST destination {a} : soft REF to MODE NEST TERTIARY {5B} .
c) MODE1 NEST source {a, 44d} : strong MODE2 NEST unit {32d} , where MODE1 deflexes to MODE2 {47a, b, c, -}.

{Examples:
a) x := 3.14
b) x
c) 3.14 }

5.2.1.2. Semantics

a) An assignation A is elaborated as follows:

  • let N and W be the {collateral} yields {a name and another value} of the destination and source of A;
  • W is assigned to {b}N;
  • the yield of A is N.

b) A value W is "assigned to" a name N, whose mode is some 'REF to MODE', as follows:
It is required that

  • N be not nil, and that
  • W be not newer in scope than N;
Case A: 'MODE' is some 'structured with FIELDS mode':
    For each 'TAG' selecting a field in W,
  • that field is assigned to the subname selected by 'TAG' in N;
Case B: 'MODE' is some 'ROWS of MODE1':
  • let V be the {old} value referred to by N;
  • it is required that the descriptors of W and V be identical;
    For each index I selecting an element in W,
  • that element is assigned to the subname selected by I in N;
Case C: 'MODE' is some 'flexible ROWS of MODE1':
  • let V be the {old} value referred to by N;
  • N is made to refer to a multiple value composed of
  1. the descriptor of W,
  2. variants {4.4.2.c} of some element {possibly a ghost element} of V;
For each index I selecting an element in W,
  • that element is assigned to the subname selected by I in N;
Other Cases {e.g., where 'MODE' is some 'PLAIN' or some 'UNITED'} :

{Observe how, given FLEX [1: 0] [1: 3] INT flexfix, the presence of the ghost element {2.1.3.4.c} ensures that the meaning of flexfix := LOC [1: 1] [1: 3] INT is well defined, but that of flexfix := LOC [1: 1] [1: 4] INT is not, since the bound pairs of the second dimension are different.}

5.2.2. Identity relations

{Identity-relations may be used to ask whether two names of the same mode are the same.
E.g., after the assignation draft := ("abc", NIL), the identity-relation next OF draft :=: REF BOOK (NIL) yields true. However, next OF draft :=: NIL yields false because it is equivalent to next OF draft :=: REF REF BOOK (NIL); the yield of next OF draft, without any coercion, is the name referring to the second field of the structured value referred to by the value of draft and, hence, is not nil.}

5.2.2.1. Syntax

a) boolean NEST identity relation {5A} : where soft balances SORT1 and SORT2 {32f} , SORT1 reference to MODE NEST TERTIARY1 {5B} , identity relator {b}, SORT2 reference to MODE NEST TERTIARY2 {5B} .
b) identity relator {a} : is {94f} token ; is not {94f} token.

{Examples:
a) next OF draft:=: REF BOOK (NIL)
b) :=: • :≠: }

{Observe that a1 [i] :=: a1 [j] is not produced by this syntax. The comparison, by an identity-relation, of transient names {2.1.3.6.c} is thus prevented.}

5.2.2.2. Semantics

The yield W of an identity-relation I is determined as follows:

  • let N1 and N2 be the {collateral} yields of the 'TERTIARY's of I;
Case A: The token of the identity-relator of I is an is-token:
  • W is true if {the name} N1 is the same as N2, and is false otherwise;
Case B: The token of the identity-relator of I is an is-not-token:
  • W is true if N1 is not the same as N2, and is false, otherwise.

5.2.3. Generators

{And as imagination bodies forth
The forms of things unknown, the poet's pen
Turns them to shapes, and gives to airy nothing
A local habitation and a name.
A Midsummer-night's Dream, William Shakespeare.}

{The elaboration of a generator, e.g., LOC REAL in xx := LOC REAL := 3.14, or of a sample-generator, e.g., [1 : n] CHAR in [1: n] CHAR u, v;, involves the creation of a name, i.e., the reservation of storage.
The use of a local-generator implies (with most implementations) the reservation of storage on a run-time stack, whereas heap-generators imply the reservation of storage in another region, termed the "heap", in which garbage-collection techniques may be used for storage retrieval. Since this is less efficient, local-generators are preferable; this is why only LOC may be omitted from sample-generators of variable-declarations.}

5.2.3.1. Syntax

{LEAP :: local ; heap primal.}
a) reference to MODE NEST LEAP generator {5C} : LEAP {94d , -} token, actual MODE NEST declarer {46a} .
b) reference to MODINE NEST LEAP sample generator {44e} : LEAP {94d , -} token, actual MODINE NEST declarer {44b, 46a} ; where (LEAP) is (local), actual MODINE NEST declarer {44b , 46a} .

{Examples:
a) LOC REAL
b) LOC REAL • REAL }
{There is no representation for the primal-symbol (see 9.4.a).}

5.2.3.2. Semantics

a) The yield W of a LEAP-generator or LEAP-sample-generator G, in an environ E, is determined as follows:

  • W is a newly created name which is made to refer {2.1.3.2.a} to the yield in E of the actual-declarer {4.4.2.d , 4.6.2.a} of G;
  • W is equal in scope to the environ E1 determined as follows:
      Case A: 'LEAP' is 'local':
      • E1 is the "local environ" {b} accessible from E;
      Case B: 'LEAP' is 'heap':
      • E1 is {the first environ created during the elaboration of the particular-program, which is} such that
      1. the primal environ {2.2.2.a} is the environ of the environ of the environ of the environ of E1 {sic}, and
      2. E1 is, or is older than, E;
      Case C: 'LEAP' is 'primal':
      • E1 is the primal environ;
  • if W is a stowed name {2.1.3.2.b}, then W is endowed with subnames {2.1.3.3.e , 2.1.3.4.g}.

{The only examples of primal-generators occur in the standard- and system-preludes {10.3.1.1.h , 10.3.1.4.b, n, o , 10.4.1.a}.
When G is a reference-to-routine-sample-generator, the mode of W is of no relevance.}

b) The "local environ" accessible from an environ E is an environ E1 determined as follows:

    If E is "nonlocal" {3.2.2.b},
    then E1 is the local environ accessible from the environ of E;
    otherwise, E1 is E.

{An environ is nonlocal if it has been established according to a serial-clause or enquiry-clause which contains no constituent mode-, identifier-, or operation-declaration, or according to a for-part {3.5.1.b} or a specification {3.4.1.j, k}.}

5.2.4. Nihils

5.2.4.1. Syntax

a) strong reference to MODE NEST nihil {5B} : nil {94f} token.

{Example:
a) NIL }

5.2.4.2. Semantics

The yield of a nihil is a nil name.

5.3. Units associated with stowed values

{In Flanders fields the poppies blow
Between the crosses, row on row, ...
In Flanders Fields, John McCrae.}

{The fields of structured values may be obtained by selections {5.3.1} and the elements of multiple values by slices {5.3.2}; the corresponding effects on stowed names are defined also.}

5.3.1. Selections

{A selection selects a field from a structured value or (if it is a "multiple selection") it selects a multiple value from a multiple value whose elements are structured values. For example, re OF z selects the first real field (usually termed the real part) of the yield of z. If z yields a name, then re OF z also yields a name, but if g yields a complex value, then re OF g yields a real value, not a name referring to one.}

5.3.1.1. Syntax

A) REFETY :: REF to ; EMPTY.
B) REFLEXETY :: REF to ; REF to flexible ; EMPTY. {REF :: reference ; transient reference.}
a) REFETY MODE1 NEST selection {5C} : MODE1 field FIELDS applied field selector with TAG {48d} , of {94f} token, weak REFETY structured with FIELDS mode NEST SECONDARY {5C} ; where (MODE1) is (ROWS of MODE2), MODE2 field FIELDS applied field selector with TAG {48d} , of {94f} token, weak REFLEXETY ROWS of structured with FIELDS mode NEST SECONDARY {5C} , where (REFETY) is derived from (REFLEXETY) {b, c, -}.
b) WHETHER (transient reference to) is derived from (REF to flexible) {a, 532a , 66a} : WHETHER true.
c) WHETHER (REFETY) is derived from (REFETY) {a, 532a , 66a} : WHETHER true.

{Examples:
re OF z • re OF z1 }

{The mode of re OF z begins with 'reference to' because that of z does.
Example:

INT age := 7; STRUCT (BOOL sex, INT age) jill;
age OF jill :=  age;
Note that the destination age OF jill yields a name because jill yields one.
After the identity-declaration
STRUCT (BOOL sex, INT age) jack = (TRUE, 9), 
age OF jack cannot be assigned to since jack is not a variable.}

5.3.1.2. Semantics

The yield W of a selection S is determined as follows:

  • let V be the yield of the SECONDARY of S;
  • it is required that V {if it is a name} be not nil;
  • W is the value selected in {2.1.3.3.a, e , 2.1.3.4.k} or the name generated from {2.1.3.4.l} V by the field-selector of S.

{A selection in a name referring to a structured value yields an existing subname {2.1.3.3.e} of that name. The name generated from a name referring to a multiple value, by way of a selection with a ROWS-of-MODE-SECONDARY (as in re OF z1), is a name which may or may not be newly created for the purpose.}

5.3.2. Slices

{Slices are obtained by subscripting, e.g., x1[i], by trimming, e.g., x1[2 : n] or by both, e.g., x2[j : n, j] or x2 [, k]. Subscripting and trimming may be done only to PRIMARYs, e.g., x1 or (p | x1 | y1) but not re OF z1. The value of a slice may be either one element of the yield of its PRIMARY or a subset of the elements; e.g., x1[i] is a real number from the row of real numbers x1, x2[i, ] is the i-th row of the matrix x2 and x2[, k] is its k-th column.}

5.3.2.1. Syntax

A) ROWSETY :: ROWS ; EMPTY.
a) REFETY MODE1 NEST slice {5D} : weak REFLEXETY ROWS1 of MODE1 NEST PRIMARY {5D} , ROWS1 leaving EMPTY NEST indexer {b, c, -} STYLE bracket, where (REFETY) is derived from (REFLEXETY) {531b, c , -}; where (MODE1) is (ROWS2 of MODE2), weak REFLEXETY ROWS1 of MODE2 NEST PRIMARY {5D} , ROWS1 leaving ROWS2 NEST indexer {b, d, -} STYLE bracket, where (REFETY) is derived from (REFLEXETY) {531b, c , -}.
{ROWS :: row ; ROWS row.}
b) row ROWS leaving ROWSETY1 ROWSETY2 NEST indexer {a, b} : row leaving ROWSETY1 NEST indexer {c, d, -}, and also {94f} token, ROWS leaving ROWSETY2 NEST indexer {b, c, d, -}.
c) row leaving EMPTY NEST indexer {a, b} : NEST subscript {e}.
d) row leaving row NEST indexer {a, b} : NEST trimmer {f}; NEST revised lower bound {g} option.
e) NEST subscript {c} : meek integral NEST unit {32d} .
f) NEST trimmer {d} : NEST lower bound {46m} option, up to {94f} token, NEST upper bound {46n} option, NEST revised lower bound {g} option.
g) NEST revised lower bound {d, f} : at {94f} token, NEST lower bound {46m} .
h) *trimscript : NEST subscript {e}; NEST trimmer {f}; NEST revised lower bound {g} option.
i) *indexer : ROWS leaving ROWSETY NEST indexer {b, c, d}.
j) *boundscript : NEST subscript {e}; NEST lower bound {46m} ; NEST upper bound {46n} ; NEST revised lower bound {g}.

{Examples:
a) x2[i, j] • x2[, j]
b) 1 : 2, j (in x2[1 : 2, j] • i, j (in x2[i, j])
c) j (in x2[1 : 2, j])
d) 1 : 2 • @0 (in x1[@0])
e) j
f) 1 : 2 @0
g) @0 }

{A subscript decreases the number of dimensions by one, but a trimmer leaves it unchanged. In rule a, 'ROWS1' reflects the number of trimscripts in the slice, and 'ROWS2' the number of these which are trimmers or revised-lower-bound-options. If the value to be sliced is a name, then the yield of the slice is also a name. Moreover, if the mode of the former name is 'reference to flexible ROWS1 of MODE', then that yield is a transient name (see 2.1.3.6.c).}

5.3.2.2. Semantics

a) The yield W of a slice S is determined as follows:

  • let V and (I1, ... , In) be the {collateral} yields of the PRIMARY of S and of the indexer {b} of S;
  • it is required that V {if it is a name} be not nil;
  • let ( (r1, s1), ..., (rn, sn)) be the descriptor of V or of the value referred to by V;
    For i = 1, ..., n,
      Case A: Ii is an integer:
      • it is required that ri ≤Ii ≤ si;
      Case B: Ii is some triplet (l, u, l'):
      • let L be ri, if l is absent, and be l otherwise;
      • let U be si, if u is absent, and be u otherwise;
      • it is required that ri ≤L and U ≤si;
      • let D be 0 if l' is absent, and be L - l¢ otherwise; {D is the amount to be subtracted from L in order to get the revised lower bound;}
      • Ii is replaced by (L, U, D);
    • W is the value selected in {2.1.3.4.a, g, i} or the name generated from {2.1.3.4.j} V by I1, ... , In.

b) The yield of an indexer I of a slice S is a trim {2.1.3.4.h} or an index {2.1.3.4.a} I1, ... , In determined as follows: • the constituent boundscripts of S are elaborated collaterally;
For i = 1 ... n, where n is the number of constituent trimscripts of S,

    Case A: the i-th trimscript is a subscript:
    • Ii is {the integer which is} the yield of that subscript;
    Case B: the i-th trimscript is a trimmer T:
    • Ii is the triplet (l, u, l'), where
      • l is the yield of the constituent lower-bound, if any, of T, and is absent, otherwise,
      • u is the yield of the constituent upper-bound, if any, of T, and is absent, otherwise,
      • l' is the yield of the constituent revised-lower-bound, if any, of T, and is 1, otherwise;
    Case C: the i-th trimscript is a revised-lower-bound-option N:
    • Ii is the triplet (absent, absent, l'), where
    • l' is the yield of the revised-lower-bound, if any, of N, and is absent otherwise.

{Observe that, if (I1, ... , In) contains no triplets, it is an index, and selects one element; otherwise, it is a trim, and selects a subset of the elements.}

{A slice from a name referring to a multiple value yields an existing subname {2.1.3.4.j} of that name if all the constituent trimscripts of that slice are subscripts. Otherwise, it yields a generated name which may or may not be newly created for the purpose. Hence, the yield of x1[1 : 2] :=: x1 [1 : 2] is not defined, although x1[1] :=: x1[1] must always yield true.}

{The various possible bounds in the yield of a slice are illustrated by the following examples, for each of which the descriptor of the value referred to by the yield is shown:

[0 : 9, 2 : 11] INT i3;
i3 [1, 3 : 10 @3] ¢ ( (3, 10)) ¢;
i3 [1, 3 : 10] ¢ ( (1, 8)) ¢;
i3 [1, 3 : ] ¢ ( (1, 9)) ¢;
i3 [1, : ] ¢ ( (1, 10)) ¢;
i3 [1, ] ¢ ( (2, 11)) ¢;
i3 [, 2] ¢ ( (0, 9)) ¢ }

5.4. Units associated with routines

{Routines are created from routine-texts {5.4.1} or from jumps {5.4.4}, and they may be "called" by calls {5.4.3}, formulas {5.4.2} or by deproceduring {6.3}.}

5.4.1. Routine texts

{A routine-text always has a formal-declarer, specifying the mode of the result, and a routine-token, viz., a colon. To the right of this colon stands a unit, which prescribes the computations to be performed when the routine is called. If there are parameters, then to the left of the formal-declarer stands a declarative containing the various formal-parameters required.
Examples:

VOID: print (x);
 (REF REAL a, REAL b) BOOL: (a < b | a := b; TRUE | FALSE).
}

5.4.1.1. Syntax

a) procedure yielding MOID NEST1 routine text {44d , 5A} : formal MOID NEST1 declarer {46b} , routine {94f} token, strong MOID NEST1 unit {32d} .
b) procedure with PARAMETERS yielding MOID NEST1 routine text {44d , 5A} : NEST1 new DECS2 declarative defining new DECS2 {e} brief pack, where DECS2 like PARAMETERS {c, d, -}, formal MOID NEST1 declarer {46b} , routine {94f} token, strong MOID NEST1 new DECS2 unit {32d} .
c) WHETHER DECS DEC like PARAMETERS PARAMETER {b, c} : WHETHER DECS like PARAMETERS {c, d, -} and DEC like PARAMETER {d, -}. {PARAMETER :: MODE parameter.}
d) WHETHER MODE TAG like MODE parameter {b, c} : WHETHER true.
e) NEST2 declarative defining new DECS2 {b, e, 34j} : formal MODE NEST2 declarer {46b} , NEST2 MODE parameter joined definition of DECS2 {41b, c} ; where (DECS2) is (DECS3 DECS4), formal MODE NEST2 declarer {46b} , NEST2 MODE parameter joined definition of DECS3 {41b, c} , and also {94f} token, NEST2 declarative defining new DECS4 {e}.
f) NEST2 MODE parameter definition of MODE TAG2 {41c} : MODE NEST2 defining identifier with TAG2 {48a} .
g) *formal MODE parameter : NEST MODE parameter definition of MODE TAG {f}.

{Examples:
a) REAL: random × 10
b) (BOOL a, b) BOOL: (a | b | FALSE)
e) BOOL a, b • BOOL a, BOOL b
f) a }

5.4.1.2. Semantics

The yield of a routine-text T, in an environ E, is the routine composed of

  1. T, and
  2. the environ necessary for {7.2.2.c} T in E.

5.4.2. Formulas

{Formulas are either dyadic or monadic: e.g., x + i or ABS x. The order of elaboration of a formula is determined by the priority of its operators; monadic formulas are elaborated first and then the dyadic ones from the highest to the lowest priority.}

5.4.2.1. Syntax

A) DYADIC :: priority PRIO.
B) MONADIC :: priority iii iii iii i.
C) ADIC :: DYADIC ; MONADIC.
D) TALLETY :: TALLY ; EMPTY.
a) MOID NEST DYADIC formula {c, 5B} : MODE1 NEST DYADIC TALLETY operand {c, -}, procedure with MODE1 parameter MODE2 parameter yielding MOID NEST applied operator with TAD {48b} , where DYADIC TAD identified in NEST {72a} , MODE2 NEST DYADIC TALLY operand {c, -}.
b) MOID NEST MONADIC formula {c, 5B} : procedure with MODE parameter yielding MOID NEST applied operator with TAM {48b} , MODE NEST MONADIC operand {c}.
c) MODE NEST ADIC operand {a, b} : firm MODE NEST ADIC formula {a, b} coercee {61b} ; where (ADIC) is (MONADIC), firm MODE NEST SECONDARY {5C} .
d) *MOID formula : MOID NEST ADIC formula {a, b}.
e) *DUO dyadic operator with TAD : DUO NEST DEFIED operator with TAD {48a, b} .
f) *MONO monadic operator with TAM : MONO NEST DEFIED operator with TAM {48a, b} .
g) *MODE operand : MODE NEST ADIC operand {c}.

{Examples:
a) -x + 1
b) -x
c) -x • 1 }

5.4.2.2. Semantics

The yield W of a formula F, in an environ E, is determined as follows:

  • let R be the routine yielded in E by the operator of F;
  • let V1, ... , Vn {n is 1 or 2} be the {collateral} yields of the operands of F, in an environ E1 established {locally, see 3.2.2.b} around E;
  • W is the yield of the calling {5.4.3.2.b} of R in E1, with V1, ... , Vn;
  • it is required that W be not newer in scope than E.

{Observe that a ↑ b is not precisely the same as ab in the usual notation; indeed, the value of (- 1 ↑ 2 + 4 = 5) and that of (4 - 1 ↑ 2 = 3) both are true, since the first minus-symbol is a monadic-operator, whereas the second is a dyadic-operator.}

5.4.3. Calls

{Calls are used to command the elaboration of routines parametrized with actual-parameters.
Examples:

sin (x) • (p | sin | cos) (x). }

5.4.3.1. Syntax

a) MOID NEST call {5D} : meek procedure with PARAMETERS yielding MOID NEST PRIMARY {5D} , actual NEST PARAMETERS {b, c} brief pack.
b) actual NEST PARAMETERS PARAMETER {a, b} : actual NEST PARAMETERS {b, c}, and also {94f} token, actual NEST PARAMETER {c}.
c) actual NEST MODE parameter {a, b} : strong MODE NEST unit {32d} .

{Examples:
a) put (stand out, x) (see 10.3.3.1.a)
b) stand out, x
c) x }

5.4.3.2. Semantics

a) The yield W of a call C, in an environ E, is determined as follows:

  • let R {a routine} and V1, ... , Vn be the {collateral} yields of the PRIMARY of C, in E, and of the constituent actual-parameters of C, in an environ E1 established {locally, see 3.2.2.b} around E;
  • W is the yield of the calling {b} of R in E1 with V1, ... , Vn;
  • it is required that W be not newer in scope than E.

b) The yield W of the "calling", of a routine R in an environ E1, possibly with {parameter} values V1, ... , Vn, is determined as follows:

  • let E2 be the environ established {3.2.2.b} upon E1, around the environ of R, according to the declarative of the declarative-pack, if any, of the routine-text of R, with the values V1, ... , Vn, if any;
  • W is the yield in E2 of the unit of the routine-text of R.

{Consider the following serial-clause:

PROC samelson = (INT n, PROC (INT) REAL f) REAL:
   BEGIN LONG REAL s := LONG 0;
      FOR i TO n DO s +:= LENG f (i) ↑ 2 OD;
      SHORTEN long sqrt (s)
   END;
samelson (m, (INT j) REAL: x1[j]).
In that context, the last call has the same effect as the following cast:
REAL (
   INT n = m, PROC (INT) REAL f = (INT j) REAL: x1[j];
   BEGIN LONG REAL s := LONG 0;
      FOR i TO n DO s +:= LENG f (i) ↑ 2 OD;
      SHORTEN long sqrt (s)
   END).

The transmission of actual-parameters is thus similar to the elaboration of identity-declarations {4.4.2.a}; see also establishment {3.2.2.b} and ascription {4.8.2.a}.}

5.4.4. Jumps

{A jump may terminate the elaboration of a series and cause some other labelled series to be elaborated in its place.
Examples:

y = IF x ≥ 0 THEN sqrt (x) ELSE GOTO princeton FI •
GOTO st pierre de chartreuse.

Alternatively, if the context expects the mode 'procedure yielding MOID', then a routine whose unit is that jump is yielded instead, as in PROC VOID m := GOTO north berwick.}

5.4.4.1. Syntax

a) strong MOID NEST jump {5A} : go to {b} option, label NEST applied identifier with TAG {48b} .
b) go to {a} : STYLE go to {94f , -} token ; STYLE go {94f , -} token, STYLE to symbol {94g, -}.

{Examples:
a) GOTO kootwijk • GO TO warsaw • zandvoort
b) GOTO • GO TO }

5.4.4.2. Semantics

A MOID-NEST-jump J, in an environ E, is elaborated as follows: • let the scene yielded in E by the label-identifier of J be composed of a series S2 and an environ E1;
Case A: 'MOID' is not any 'procedure yielding MOID1':

  • let S1 be the series of the smallest {1.1.3.2.g} serial-clause containing S2;
  • the elaboration of S1 in E1, or of any series in E1 elaborated in its place, is terminated {2.1.4.3.e};
  • S2 in E1 is elaborated "in place of" S1 in E1;
Case B: 'MOID' is some 'procedure yielding MOID1':
  • J in E {is completed and} yields the routine composed of
  1. a new MOID-NEST-routine-text whose unit is akin {1.1.3.2.k} to J,
  2. E1.

5.5. Units associated with values of any mode

5.5.1. Casts

{Casts may be used to provide a strong position. For example, REF REAL (xx) in REF REAL (xx) := 1, REF BOOK (NIL) in next OF draft :=: REF BOOK (NIL) and STRING (p | c | r) in s +:= STRING (p | c | r).}

5.5.1.1. Syntax

a) MOID NEST cast {5D} : formal MOID NEST declarer {46b} , strong MOID NEST ENCLOSED clause {31a, 33a, c, d, e, 34a, 35a, -}.

{Example:
a) REF BOOK (NIL) }

{The yield of a cast is that of its ENCLOSED-clause, by way of pre-elaboration {2.1.4.1.c}.}

5.5.2. Skips

5.5.2.1. Syntax

a) strong MOID NEST skip {5A} : skip {94f} token.

5.5.2.2. Semantics

The yield of a skip is some {undefined} value equal in scope to the primal environ.

{The mode of the yield of a MOID-skip is 'MOID'. A void-skip serves as a dummy statement and may be used, for example, after a label which marks the end of a serial-clause.}

PART III - Context Dependence

{This Part deals with those rules which do not alter the underlying syntactical structure:

  • the transformations of modes implicitly defined by the context, with their accompanying actions;
  • the syntax needed for the equivalence of modes and for the safe application of the properties kept in the nests.}

6. Coercion

{The coercions produce a coercend from a coercee according to three criteria: the a priori mode of the coercend before the application of any coercion, the a posteriori mode of the coercee required after those coercions, and the syntactic position or "sort" of the coercee. Coercions may be cascaded.

There are six possible coercions, termed "deproceduring", "dereferencing", "uniting", "widening", "rowing" and "voiding". Each coercion, except "uniting", prescribes a corresponding dynamic effect on the associated values. Hence, a number of primitive actions can be programmed implicitly by coercions.}


«Table of contents»

6.1. Coercees

{A coercee is a construct whose production tree may begin a sequence of coercions ending in a coercend. The order of (completion of) the elaboration of the coercions is therefore from the coercend to the coercee (hence the choice of these paranotions). For example, i in REAL (i) is a coercee whose production tree involves 'widened to' and 'dereferenced to', in that order, in passing from the coercee to the coercend. Note that the dereferencing must be completed before the widening takes place.

The relevant production tree (with elision of 'NEST', 'applied' and 'with TAG', and with invisible subtrees omitted) is:

                            'strong real identifier coercee'
                             |
                             | 6.1.1.a
                             |
 -------------------------->'widened to real identifier'
 |                           |
widening coercion            | 6.5.1.a
 |                           |
 |--------------------------'dereferenced to integral identifier'
 |                           |
dereferencing coercion       | 6.2.1.a
 |                           |
 ---------------------------'unchanged from reference to integral identifier'
                             |
                             | 6.1.1.f
                             |
                            'reference to integral identifier' (coercend)
                             |
                             | 4.8.1.b
                             |
                            'letter i symbol'. }

}

6.1.1. Syntax

A) STRONG {a, 66a} :: FIRM {B}; widened to {65a, b, c, d} ; rowed to {66a} ; voided to {67a, b} .
B) FIRM {A, b} :: MEEK {c}; united to {64a} .
C) MEEK {B, c, d, 62a , 63a, 64a, 65a, b, c, d} :: unchanged from {f}; dereferenced to {62a} ; deprocedured to {63a} .
D) SOFT {e, 63b} :: unchanged from {f}; softly deprocedured to {63b} .
E) FORM :: MORF ; COMORF.
F) MORF :: NEST selection ; NEST slice ; NEST routine text ; NEST ADIC formula ; NEST call ; NEST applied identifier with TAG.
G) COMORF :: NEST assignation ; NEST identity relation ; NEST LEAP generator ; NEST cast ; NEST denoter ; NEST format text.
a) strong MOID FORM coercee {5A, B, C, D , A341i} : where (FORM) is (MORF), STRONG {A} MOID MORF ; where (FORM) is (COMORF), STRONG {A} MOID COMORF, unless (STRONG MOID) is (deprocedured to void).
b) firm MODE FORM coercee {5A, B, C, D , 542c} : FIRM {B} MODE FORM.
c) meek MOID FORM coercee {5A, B, C, D} : MEEK {C} MOID FORM.
d) weak REFETY STOWED FORM coercee {5A, B, C, D} : MEEK {C} REFETY STOWED FORM, unless (MEEK) is (dereferenced to) and (REFETY) is (EMPTY).
e) soft MODE FORM coercee {5A, B, C, D} : SOFT {D} MODE FORM.
f) unchanged from MOID FORM {C, D, 67a, b} : MOID FORM.
g) *SORT MOID coercee : SORT MOID FORM coercee {a, b, c, d, e}.
h) *MOID coercend : MOID FORM.

{Examples:
a) 3.14 (in x := 3.14)
b) 3.14 (in x + 3.14)
c) sin (in sin (x))
d) x1 (in x1[2] := 3.14)
e) x (in x := 3.14) }

{For 'MOID FORM' (rule f), see the cross-references inserted in sections 5.1.A, B, C, D before "coercee". Note, however, that a 'MOID FORM' may be a blind alley. Blind alleys within this chapter are not indicated.}

{There are five sorts of syntactic position. They are:

  • "strong" positions, i.e., actual-parameters, e.g., x in sin (x), sources, e.g., x in y := x, the ENCLOSED-clause of a cast, e.g., (NIL) in REF BOOK (NIL), and statements, e.g., y := x in (y := x; x := 0);
  • "firm" positions, i.e., operands, e.g., x in x + y;
  • "meek" positions, i.e., enquiry-clauses, e.g., x > 0 in (x > 0 | x | 0), boundscripts, e.g., i in x1 [i], and the PRIMARY of a call, e.g., sin in sin (x);
  • "weak" positions, i.e., the SECONDARY of a selection and the PRIMARY of a slice, e.g., x1 in x1 [i];
  • "soft" positions, i.e., destinations, e.g., x in x := y and one of the TERTIARYs of an identity-relation, e.g., x in xx :=: x.

Strong positions also arise in balancing {3.2.1.e}.

In strong positions, all six coercions may occur; in firm positions, rowing, widening and voiding are forbidden; in meek and weak positions, uniting is forbidden also, and in soft positions only deproceduring is allowed. However, a dereferenced-to-STOWED-FORM may not be directly descended from a weak-STOWED-FORM-coercee (rule d) for, otherwise, x := x1 [i] would be syntactically ambiguous (although, in this case, not semantically). Also, a deprocedured-to-void-COMORF may not be directly descended from a strong-void-COMORF-coercee (rule a) for, otherwise,

 (PROC VOID engelfriet; PROC VOID rijpens = SKIP; engelfriet := rijpens; SKIP)
would be ambiguous.}

6.2. Dereferencing

{Dereferencing serves to obtain the value referred to by a name, as in x := y, where y yields a name referring to a real number and it is this number which is assigned to the name yielded by x. The a priori mode of y, regarded as a coercend, is 'reference to real' and its a posteriori mode, when y is regarded as a coercee, is 'real'.}

6.2.1. Syntax

a) dereferenced to {61C} MODE1 FORM : MEEK {61C} REF to MODE2 FORM, where MODE2 deflexes to MODE1 {47a, b, c , -}.

{Example:
a) x (in REAL (x))}

6.2.2. Semantics

The yield W of a dereferenced-to-MODE-FORM F is determined as follows:

  • let {the name} N be the yield of the MEEK-FORM of F;
  • it is required that N be not nil;
  • W is the value referred to by N.

6.3. Deproceduring

{Deproceduring is used when a routine without parameters is to be called. E.g., in x := random, the routine yielded by random is called and the real number yielded is assigned; the a posteriori mode of random is 'real'. Syntactically, an initial 'procedure yielding' is removed from the a priori mode.}

6.3.1. Syntax

a) deprocedured to {61C , 67a} MOID FORM : MEEK {61C} procedure yielding MOID FORM.
b) softly deprocedured to {61D} MODE FORM : SOFT {61D} procedure yielding MODE FORM.

{Examples:
a) random (in REAL (random))
b) x or y (in x or y := 3.14, see 1.1.2)}

6.3.2. Semantics

The yield W of a deprocedured-to-MOID-FORM or softly-deprocedured-to-MOID-FORM F, in an environ E, is determined as follows:

  • let {the routine} R be the yield in E of the direct descendent of F;
  • W is the yield of the calling {5.4.3.2.b} of R in E;
  • it is required that W be not newer in scope than E.

6.4. Uniting

{Uniting does not change the mode of the run-time value yielded by a construct, but simply gives more freedom to it. That value must be acceptable to not just that one mode, but rather to the whole of a given set of modes. However, after uniting, that value may be subject to a primitive action only after being dynamically tested in a conformity-clause {3.4.1.q}; indeed, no primitive action can be programmed with a construct of a 'UNITED' mode (except to assign it to a UNITED-variable, of course).
Example:

UNION (BOOL, CHAR) t, v;
t := "a"; t := TRUE; v := t.}

6.4.1. Syntax

a) united to {61B} UNITED FORM : MEEK {61C} MOID FORM, where MOID unites to UNITED {b}.
b) WHETHER MOID1 unites to MOID2 {a, 34i , 71m} : where MOID1 equivalent MOID2 {73a} , WHETHER false ; unless MOID1 equivalent MOID2 {73a} , WHETHER safe MOODS1 subset of safe MOODS2 {73l, m, n} , where (MOODS1) is (MOID1) or (union of MOODS1 mode) is (MOID1), where (MOODS2) is (MOID2) or (union of MOODS2 mode) is (MOID2).

{Examples:
a) x (in uir := x) •
      u (in UNION (CHAR, INT, VOID) (u), in a reach containing UNION (INT, VOID) u := EMPTY) }

6.5. Widening

{Widening transforms integers to real numbers, real numbers to complex numbers (in both cases, with the same size), a value of mode 'BITS' to an unpacked vector of truth values, or a value of mode 'BYTES' to an unpacked vector of characters.
For example, in z := 1, the yield of 1 is widened to the real number 1.0 and then to the complex number (1.0, 0.0); syntactically, the a priori mode specified by INT is changed to that specified by REAL and then to that specified by COMPL.}

6.5.1. Syntax

A) BITS :: structured with row of boolean field SITHETY letter aleph mode.
B) BYTES :: structured with row of character field SITHETY letter aleph mode.
C) SITHETY :: LENGTH LENGTHETY ; SHORTH SHORTHETY ; EMPTY.
D) LENGTH :: letter l letter o letter n letter g.
E) SHORTH :: letter s letter h letter o letter r letter t.
F) LENGTHETY :: LENGTH LENGTHETY ; EMPTY.
G) SHORTHETY :: SHORTH SHORTHETY ; EMPTY.
a) widened to {b, 61A} SIZETY real FORM : MEEK {61C} SIZETY integral FORM.
{SIZETY :: long LONGSETY ; short SHORTSETY ; EMPTY.}
b) widened to {61A} structured with SIZETY real field letter r letter e SIZETY real field letter i letter m mode FORM : MEEK {61C} SIZETY real FORM ; widened to {a} SIZETY real FORM.
c) widened to {61A} row of boolean FORM : MEEK {61C} BITS FORM.
d) widened to {61A} row of character FORM : MEEK {61C} BYTES FORM.

{Examples:
a) 1 (in x := 1)
b) 1.0 (in z := 1.0) • 1 (in z := 1)
c) 2r101 (in [   ] BOOL (2r101))
d) r (in [   ] CHAR (r), see 1.1.2)

6.5.2. Semantics

The yield W of a widened-to-MODE-FORM F is determined as follows:
• let V be the yield of the direct descendent of F;
Case A: 'MODE' is some 'SIZETY real':

  • W is the real number widenable from {2.1.3.1.e} V;
Case B: 'MODE' is some 'structured with SIZETY real letter r letter e SIZETY real letter i letter m mode':
  • W is {the complex number which is} a structured value whose fields are respectively V and the real number 0 of the same size {2.1.3.1.b} as V;
Case C: 'MODE' is 'row of boolean' or 'row of character':
  • W is the {only} field of V.

6.6. Rowing

{Rowing permits the building of a multiple value from a single element. If the latter is a name then the result of rowing may also be a name referring to that multiple value.
Example:

[1 : 1] REAL b1 := 4.13 }

6.6.1. Syntax

a) rowed to {61A} REFETY ROWS1 of MODE FORM : where (ROWS1) is (row), STRONG {61A} REFLEXETY MODE FORM, where (REFETY) is derived from (REFLEXETY) {531b, c , -}; where (ROWS1) is (row ROWS2), STRONG {61A} REFLEXETY ROWS2 of MODE FORM, where (REFETY) is derived from (REFLEXETY) {531b, c , -}.

{Examples:
a) 4.13 (in [1 : 1] REAL b1 := 4.13) • x1 (in [1 : 1, 1 : n] REAL b2 := x1) }

6.6.2. Semantics

a) The yield W of a rowed-to-REFETY-ROWS1-of-MODE-FORM F is determined as follows:
• let V be the yield of the STRONG-FORM of F;
Case A: 'REFETY' is 'EMPTY':

  • W is the multiple value "built" {b} from V for 'ROWS1';
Case B: 'REFETY' is 'REF to':
    If V is nil,
    then W is a nil name;
    otherwise, W is the name "built" {c} from V for 'ROWS1'.

b) The multiple value W "built" from a value V, for some 'ROWS1', is determined as follows:
Case A: 'ROWS1' is 'row':

  • W is composed of
  1. a descriptor ( (1, 1)),
  2. {one element} V;
Case B: 'ROWS1' is some 'row ROWS2':
  • let the descriptor of V be ( (l1, u1), ..., (ln, un));
  • W is composed of
    1. a descriptor ( (1, 1), (l1, u1), ..., (ln, un)),
    2. the elements of V:
  • the element selected by an index (i1, ... , in) in V is that selected by (1, i1, ... , in) in W.

c) The name N1 "built" from a name N, for some 'ROWS1', is determined as follows:
N1 is a name {not necessarily newly created}, equal in scope to N and referring to the multiple value built {b}, for 'ROWS1', from the value referred to by N;
Case A: 'ROWS1' is 'row':

  • the {only} subname of N1 is N;
Case B: 'ROWS1' is some 'row ROWS2':
  • the subname of N1 selected by (1, i1, ... , in) is the subname of N selected by (i1, ... , in).

6.7. Voiding

{Voiding is used to discard the yield of some unit whose primary purpose is to cause its side-effects; the a posteriori mode is then simply 'void'. For example, in x:=1; y:=1;, the assignation y:=1 is voided, and in PROC t = INT: ENTIER (random × 100); t;, the applied-identifier t is voided after a deproceduring, which prescribes the calling of a routine.
Assignations and other COMORFs are voided without any deproceduring so that, in PROC VOID p: p := finish, the assignation p := finish does not prescribe an unexpected calling of the routine finish.}

6.7.1. Syntax

A) NONPROC :: PLAIN ; STOWED ; REF to NONPROC ; procedure with PARAMETERS yielding MOID ; UNITED.
a) voided to {61A} void MORF : deprocedured to {63a} NONPROC MORF ; unchanged from {61f} NONPROC MORF.
b) voided to {61A} void COMORF : unchanged from {61f} MODE COMORF.

{Examples:
a) random (in SKIP; random;) •
      next random (last random)
      (in SKIP; next random (last random);)
b) PROC VOID (pp) (in PROC PROC VOID pp = PROC VOID: (print (1);
      VOID: print (2)); PROC VOID (pp);) }

6.7.2. Semantics

The elaboration of a voided-to-void-FORM consists of that of its direct descendent, and yields empty.

7. Modes and nests

{The identification of a property in a nest is the static counterpart of the dynamic determination (4.8.2.b) of a value in an environ: the search is conducted from the newest (youngest) level towards the previous (older) ones.

Modes are composed from the primitive modes, such as 'boolean', with the aid of 'HEAD's, such as 'structured with', and they may be recursive. Recursive modes spelled in different ways may nevertheless be equivalent. The syntax tests the equivalence of such modes by proving that it is impossible to find any discrepancy between their respective structures or component modes.

A number of unsafe uses of properties are prevented. An identifier or mode-indication is not declared more than once in each reach. The modes of the operands of a formula do not determine more than one operation. Recursions in modes do not cause the creation of dynamic objects of unlimited size and do not allow ambiguous coercions.}


«Table of contents»

7.1. Independence of properties

{The following syntax determines whether two properties (i.e., two 'PROP's), such as those corresponding to REAL x and INT x, may or may not be enveloped by the same 'LAYER'.}

7.1.1. Syntax

A) PREF :: procedure yielding ; REF to.
B) NONPREF :: PLAIN ; STOWED ; procedure with PARAMETERS yielding MOID ; UNITED ; void.
C) *PREFSETY :: PREF PREFSETY ; EMPTY.
{PROP :: DEC ; LAB ; FIELD.
QUALITY :: MODE ; MOID TALLY ; DYADIC ; label ; MODE field.
TAX :: TAG ; TAB ; TAD ; TAM.
TAO :: TAD ; TAM.}
a) WHETHER PROP1 independent PROPS2 PROP2 {a, 48a, c , 72a} : WHETHER PROP1 independent PROPS2 {a, c} and PROP1 independent PROP2 {c}.
b) WHETHER PROP independent EMPTY {48a, c , 72a} : WHETHER true.
c) WHETHER QUALITY1 TAX1 independent QUALITY2 TAX2 {a, 48a, c , 72a} : unless (TAX1) is (TAX2), WHETHER true ; where (TAX1) is (TAX2) and (TAX1) is (TAO), WHETHER QUALITY1 independent QUALITY2 {d}.
d) WHETHER QUALITY1 independent QUALITY2 {c} : where QUALITY1 related QUALITY2 {e, f, g, h, i, j, -}, WHETHER false ; unless QUALITY1 related QUALITY2 {e, f, g, h, i, j, -}, WHETHER true.
e) WHETHER MONO related DUO {d} : WHETHER false.
f) WHETHER DUO related MONO {d} : WHETHER false.
g) WHETHER PRAM related DYADIC {d} : WHETHER false.
h) WHETHER DYADIC related PRAM {d} : WHETHER false.
i) WHETHER procedure with MODE1 parameter MODE2 parameter yielding MOID1 related procedure with MODE3 parameter MODE4 parameter yielding MOID2 {d} : WHETHER MODE1 firmly related MODE3 {k} and MODE2 firmly related MODE4 {k}.
j) WHETHER procedure with MODE1 parameter yielding MOID1 related procedure with MODE2 parameter yielding MOID2 {d} : WHETHER MODE1 firmly related MODE2 {k}.
k) WHETHER MOID1 firmly related MOID2 {i, j} : WHETHER MOODS1 is firm MOID2 {l, m} or MOODS2 is firm MOID1 {l, m}, where (MOODS1) is (MOID1) or (union of MOODS1 mode) is (MOID1), where (MOODS2) is (MOID2) or (union of MOODS2 mode) is (MOID2).
l) WHETHER MOODS MOOD is firm MOID {k, l} : WHETHER MOODS is firm MOID {l, m} or MOOD is firm MOID {m}.
m) WHETHER MOID1 is firm MOID2 {k, l, n, 47f} : WHETHER MOID1 equivalent MOID2 {73a} or MOID1 unites to MOID2 {64b} or MOID1 deprefs to firm MOID2 {n}.
n) WHETHER MOID1 deprefs to firm MOID2 {m} : where (MOID1) is (PREF MOID3), WHETHER MOID5 is firm MOID2 {m}, where MOID3 deflexes to MOID5 {47a, b, c} ; where (MOID1) is (NONPREF), WHETHER false.

{To prevent the ambiguous application of indicators, as in REAL x, INT x; x:=0, certain restrictions are imposed on defining-indicators contained in a given reach. These are enforced by the syntactic test for "independence" of properties enveloped by a given 'LAYER' (rules a, b, c). A sufficient condition, not satisfied in the example above, for the independence of a pair of properties, each being some 'QUALITY TAX', is that the 'TAX's differ (rule c). For 'TAX's which are not some 'TAO', this condition is also necessary, so that even REAL x, INT x; SKIP is not a serial-clause.

For two properties 'QUALITY1 TAO' and 'QUALITY2 TAO' the test for independence is more complicated, as is exemplified by the serial-clause

OP + = (INT i) BOOL: TRUE, OP + = (INT i , j) INT: 1, OP + = (INT i, BOOL j) INT: 2,
   PRIO + = 6;
   0 + + 0 ¢ = 2 ¢.
Ambiguities would be present in
PRIO + = 6, + = 7; 1 + 2 * 3 ¢ 7 or 9 ? ¢,
in
OP Z = (INT i) INT: 1, MODE Z = INT;
   Z i ¢ formula or declaration? ¢; SKIP,
and in
OP ? = (UNION (REF REAL, CHAR) a) INT: 1, OP ? = (REAL a) INT: 2;
   ? LOC REAL  ¢ 1 or 2 ? ¢.

In such cases a test is made that the two 'QUALITY's are independent (rules c, d). A 'MOID TALLY' is never independent of any 'QUALITY' (rule d). A 'MONO' is always independent of a 'DUO' (rules d, e, f) and both are independent of a 'DYADIC' (i.e., of a 'priority PRIO') (rules d, g, h). In the case of two 'PRAM's which are both 'MONO' or both 'DUO', ambiguities could arise if the corresponding parameter modes were "firmly related", i.e., if some (pair of) operand mode (s) could be firmly coerced to the (pair of) parameter mode (s) of either 'PRAM' (rules i, j). In the example with the two definitions of ?, the two 'PRAM's are related since the modes specified by UNION (REF REAL, CHAR) and by REAL are firmly related, the mode specified by REF REAL being firmly coercible to either one.

It may be shown that two modes are firmly related if one of them, or some component 'MOOD' of one of them, may be firmly coerced to the other (rules k, l), which requires a sequence of zero or more meek coercions followed by at most one uniting {6.4.1.a}. The possibility or otherwise of such a sequence of coercions between two modes is determined by the predicate 'is firm' (rules m, n).

A 'PROP1' also renders inaccessible a 'PROP2' in an outer 'LAYER' if that 'PROP2' is not independent of 'PROP1'; e.g.,

BEGIN INT x;
   BEGIN REAL x; ¢ here the 'PROP1' is 'reference to real letter x' ¢
      SKIP
   END
END
and likewise
BEGIN OP ? = (INT i) INT: l, INT k := 2;
   BEGIN OP ? = (REF INT i) INT: 3;
     ? k ¢ delivers 3, but ? 4 could not occur here because its operator is inaccessible ¢
   END
END.
}

7.2. Identification in nests

{This section ensures that for each applied-indicator there is a corresponding property in some suitable 'LAYER' of the nest.}

7.2.1. Syntax

{PROPSETY :: PROPS ; EMPTY.
PROPS :: PROP ; PROPS PROP.
PROP :: DEC ; LAB ; FIELD.
QUALITY :: MODE ; MOID TALLY ; DYADIC ; label ; MODE field.
TAX :: TAG ; TAB ; TAD ; TAM.}

a) WHETHER PROP identified in NEST new PROPSETY {a, 48b , 542a} : where PROP resides in PROPSETY {b, c, -}, WHETHER true ; where PROP independent PROPSETY {71a, b, c} , WHETHER PROP identified in NEST {a, -}.
b) WHETHER PROP1 resides in PROPS2 PROP2 {a, b, 48d} : WHETHER PROP1 resides in PROP2 {c, -} or PROP1 resides in PROPS2 {b, c, -}.
c) WHETHER QUALITY1 TAX resides in QUALITY2 TAX {a, b, 48d} : where (QUALITY1) is (label) or (QUALITY1) is (DYADIC) or (QUALITY1) is (MODE field), WHETHER (QUALITY1) is (QUALITY2) ; where (QUALITY1) is (MOID1 TALLETY) and (QUALITY2) is (MOID2 TALLETY), WHETHER MOID1 equivalent MOID2 {73a} .

{A nest, except the primal one (which is just 'new'), is some 'NEST LAYER' (i.e., some 'NEST new PROPSETY'). A 'PROP' is identified by first looking for it in that 'LAYER' (rule a). If the 'PROP' is some 'label TAX' or 'DYADIC TAX', then a simple match of the 'PROP's is a sufficient test (rule c). If the 'PROP' is some 'MOID TALLETY TAX', then the mode equivalencing mechanism must be invoked (rule c). If it is not found in the 'LAYER', then the search continues with the 'NEST' (without that 'LAYER'), provided that it is independent of all 'PROP's in that 'LAYER'; otherwise the search is abandoned (rule a). Note that rules b and c do double duty in that they are also used to check the validity of applied-field-selectors {4.8.1.d}.}

7.2.2. Semantics

a) If some NEST-range R {3.0.1.f} contains an applied-indicator I {4.8.1.b} of which there is a descendent where-PROP-identified-in-NEST-LAYER, but no descendent where-PROP-identified-in-NEST, then R is the "defining range" of that I. {Note that 'NEST' is always the nest in force just outside the range.}

b) A QUALITY-applied-indicator-with-TAX I whose defining NEST-range {a} is R "identifies" the QUALITY-NEST-LAYER-defining-indicator-with-TAX contained in R.

{For example, in

 (¢ 1 ¢ REAL i = 2.0; (¢ 2 ¢ INT i = 1; (¢ 3 ¢ REAL x; print (i) ¢ 3 ¢ ) ¢  2 ¢ ) ¢ 1 ¢)
there are three ranges. The applied-identifier i in print (i) is forced, by the syntax, to be an integral-NEST-new-real-letter-i-new-integral-letter-i-new-reference-to-real-letter-x-applied-identifier-with-letter-i {4.8.1.b}. Its defining range is the NEST-new-real-letter-i-serial-clause-defining-new-integral-letter-i {3.2.1.a} numbered ¢ 2 ¢, it identifies the defining-identifier i contained in INT i (not the one in REAL i), and its mode is 'integral'.}

{By a similar mechanism, a DYADIC-formula {5.4.2.1.a} may be said to "identify" that DYADIC-defining-operator {4.8.1.a} which determines its priority.}

c) The environ E "necessary for" a construct C in an environ E1 is determined as follows:
If E1 is the primal environ {2.2.2.a },
then E is E1;
otherwise, letting E1 be composed of a locale L corresponding to some 'PROPSETY' and another environ E2,
If C contains any QUALITY-applied-indicator-with-TAX

  • which does not identify {b} a defining-indicator contained in C,
  • which is not a mode-indication directly descended from a formal- or virtual-declarer, and
  • which is such that the predicate 'where QUALITY TAX resides in PROPSETY' {7.2.1.b} holds,
then E is E1;
otherwise, {L is not necessary for C and} E is the environ necessary for C in E2.

{The environ necessary for a construct is used in the semantics of routine-texts {5.4.1.2} and in "establishing" {3.2.2.b}. For example, in
¢ 2 ¢ PROC VOID pp; INT n; (¢ 1 ¢ PROC p = VOID: print (n); pp := p)
if E1 and E2 are the environs established by the elaboration of the serial-clauses marked by the comments ¢ 1 ¢ and ¢ 2 ¢, then E2 is the environ necessary in E1 for the routine-text VOID: print (n), and so the routine yielded by p in E1 is composed of that routine-text together with E2 {5.4.1.2}. Therefore, the scope of that routine is the scope of E2 {2.1.3.5.c} and hence the assignment {5.2.1.2.b} invoked by pp := p is well defined.}

7.3. Equivalence of modes

{The equivalence or nonequivalence of 'MOID's is determined in this section. For a discussion of equivalent 'MOID's see 2.1.1.2.}

{One way of viewing recursive modes is to consider them as infinite trees. Such a "mode tree" is obtained by repeatedly substituting in some spelling, for each 'MU application', the 'MODE' of the corresponding 'MU definition of MODE'. Thus, the spelling 'mui definition of structured with integral field letter i reference to mui application field letter n mode' would give rise to the following mode tree:


                                             |
 ----------------------------------------------------------
 |                |                            |          |
'structured with' |                            |         'mode'
                  |                            |
 --------------------                -------------------
 |          |       |                |         |       |
'integral' 'field' 'letter i'        |       'field' 'letter n'
                               ---------------
                               |             |
                              'reference to' |
                                             |
 ----------------------------------------------------------
 |                |                            |          |
'structured with' |                            |         'mode'
                  |                            |
 --------------------                -------------------
 |          |       |                |         |       |
'integral' 'field' 'letter i'        |       'field' 'letter n'
                               ---------------
                               |             |
                              'reference to' |
                                             |
                                            (et cetera).

Two spellings are equivalent if and only if they give rise to identical mode trees. The equivalence syntax tests the equivalence of two spellings by, as it were, simultaneously developing the two trees until a difference is found (resulting in a blind alley) or until it becomes apparent that no difference can be found. The growing production tree reflects to some extent the structure of the mode trees.}

7.3.1. Syntax

A) SAFE :: safe ; MU has MODE SAFE ; yin SAFE ; yang SAFE ; remember MOID1 MOID2 SAFE.
B) HEAD :: PLAIN ; PREF {71A} ; structured with ; FLEXETY ROWS of ; procedure with ; union of ; void.
C) TAILETY :: MOID ; FIELDS mode ; PARAMETERS yielding MOID ; MOODS mode ; EMPTY.
D) PARTS :: PART ; PARTS PART.
E) PART :: FIELD ; PARAMETER.
a) WHETHER MOID1 equivalent MOID2 {64b , 71m, 72c} : WHETHER safe MOID1 equivalent safe MOID2 {b}.
b) WHETHER SAFE1 MOID1 equivalent SAFE2 MOID2 {a, b, e, i, j, n} : where (SAFE1) contains (remember MOID1 MOID2) or (SAFE2) contains (remember MOID2 MOID1), WHETHER true ; unless (SAFE1) contains (remember MOID1 MOID2) or (SAFE2) contains (remember MOID2 MOID1), WHETHER (HEAD3) is (HEAD4) and remember MOID1 MOID2 SAFE3 TAILETY3 equivalent SAFE4 TAILETY4 {b, d, e, k, q, -}, where SAFE3 HEAD3 TAILETY3 develops from SAFE1 MOID1 {c} and SAFE4 HEAD4 TAILETY4 develops from SAFE2 MOID2 {c}.
c) WHETHER SAFE2 HEAD TAILETY develops from SAFE1 MOID {b, c} : where (MOID) is (HEAD TAILETY), WHETHER (HEAD) shields SAFE1 to SAFE2 {74a, b, c, d , -}; where (MOID) is (MU definition of MODE), unless (SAFE1) contains (MU has), WHETHER SAFE2 HEAD TAILETY develops from MU has MODE SAFE1 MODE {c}; where (MOID) is (MU application) and (SAFE1) is (NOTION MU has MODE SAFE3) and (NOTION) contains (yin) and (NOTION) contains (yang), WHETHER SAFE2 HEAD TAILETY develops from SAFE1 MODE {c}.
d) WHETHER SAFE1 FIELDS1 mode equivalent SAFE2 FIELDS2 mode {b} : WHETHER SAFE1 FIELDS1 equivalent SAFE2 FIELDS2 {f, g, h, i}.
e) WHETHER SAFE1 PARAMETERS1 yielding MOID1 equivalent SAFE2 PARAMETERS2 yielding MOID2 {b} : WHETHER SAFE1 PARAMETERS1 equivalent SAFE2 PARAMETERS2 {f, g, h, j} and SAFE1 MOID1 equivalent SAFE2 MOID2 {b}.
f) WHETHER SAFE1 PARTS1 PART1 equivalent SAFE2 PARTS2 PART2 {d, e, f} : WHETHER SAFE1 PARTS1 equivalent SAFE2 PARTS2 {f, g, h, i, j} and SAFE1 PART1 equivalent SAFE2 PART2 {i, j}.
g) WHETHER SAFE1 PARTS1 PART1 equivalent SAFE2 PART2 {d, e, f} : WHETHER false.
h) WHETHER SAFE1 PART1 equivalent SAFE2 PARTS2 PART2 {d, e, f} : WHETHER false.
i) WHETHER SAFE1 MODE1 field TAG1 equivalent SAFE2 MODE2 field TAG2 {d, f} : WHETHER (TAG1) is (TAG2) and SAFE1 MODE1 equivalent SAFE2 MODE2 {b}.
j) WHETHER SAFE1 MODE1 parameter equivalent SAFE2 MODE2 parameter {e, f} : WHETHER SAFE1 MODE1 equivalent SAFE2 MODE2 {b}.
k) WHETHER SAFE1 MOODS1 mode equivalent SAFE2 MOODS2 mode {b} : WHETHER SAFE1 MOODS1 suhset of SAFE2 MOODS2 {l, m, n} and SAFE2 MOODS2 subset of SAFE1 MOODS1 {l, m, n} and MOODS1 number equals MOODS2 number {o, p}.
l) WHETHER SAFE1 MOODS1 MOOD1 subset of SAFE2 MOODS2 {k, l, 46s , 64b} : WHETHER SAFE1 MOODS1 subset of SAFE2 MOODS2 {l, m, n} and SAFE1 MOOD1 subset of SAFE2 MOODS2 {m, n}.
m) WHETHER SAFE1 MOOD1 subset of SAFE2 MOODS2 MOOD2 {k, l, m, 46s , 64b} : WHETHER SAFE1 MOOD1 subset of SAFE2 MOODS2 {m, n} or SAFE1 MOOD1 subset of SAFE2 MOOD2 {n}.
n) WHETHER SAFE1 MOOD1 subset of SAFE2 MOOD2 {k, l, m, 64b} : WHETHER SAFE1 MOOD1 equivalent SAFE2 MOOD2 {b}.
o) WHETHER MOODS1 MOOD1 number equals MOODS2 MOOD2 number {k, o} : WHETHER MOODS1 number equals MOODS2 number {o, p, -}.
p) WHETHER MOOD1 number equals MOOD2 number {k, o} : WHETHER true.
q) WHETHER SAFE1 EMPTY equivalent SAFE2 EMPTY {b} : WHETHER true.

{Rule a introduces the 'SAFE's which are used as associative memories during the determination of equivalence. There are two of them, one belonging to each mode. Rule b draws an immediate conclusion if the 'MOID's under consideration are already remembered (see below) in an appropriate 'SAFE' in the form 'remember MOID1 MOID2'. If this is not the case, then the two 'MOID's are first remembered in a 'SAFE' (the one on the left) and then each 'MOID' is developed (rule c) and split into its 'HEAD' and its 'TAILETY', e.g., 'reference to real' is split into 'reference to' and 'real'.

If the 'HEAD's differ, then the matter is settled (rule b); otherwise the 'TAILETY's are analyzed according to their structure (which must be the same if the 'HEAD's are identical). In each case, except where the 'HEAD's were 'union of', the equivalence is determined by examining the corresponding components, according to the following scheme:

rule'TAILETY'components
d'FIELDS mode''FIELDS'
e'PARAMETERS yielding MOID''PARAMETERS' and 'MOID'
f'FIELDS FIELD''FIELDS' and 'FIELD'
f'PARAMETERS PARAMETER''PARAMETERS' and 'PARAMETER'
i'MODE field TAG''MODE' and 'TAG'
j'MODE parameter''MODE'

In the case of unions, the 'TAILETY's are of the form 'MOODS1 mode' and 'MOODS2 mode'. Since 'MOOD's within equivalent unions may commute, as in the modes specified by UNION (REAL, INT) and UNION (INT, REAL), the equivalence is determined by checking that 'MOODS1' is a subset of 'MOODS2' and that 'MOODS2' is a subset of 'MOODS1', where the subset test, of course, invokes the equivalence test recursively (rules k, l, m, n, o, p).

A 'MOID' is developed (rule c) into the form 'HEAD TAILETY' by determining that

  1. it is already of that form: in which case markers ('yin' and 'yang') may be placed in its 'SAFE' for the later determination of well-formedness (see 7.4 );
  2. it is some 'MU definition of MODE': in which case 'MU has MODE' is stored in its 'SAFE' (provided that this particular 'MU' is not there already) and the 'MODE' is developed;
  3. it is some 'MU application': in which case there must be some 'MU has MODE' in its 'SAFE' already. That 'MODE' is then developed after a well-formedness check (see 7.4 ) consisting of the determination that there is at least one 'yin' and at least one 'yang' in the 'SAFE' which is more recent than the 'MU has MODE'.
}

{Before a pair of 'TAILETY's is tested for equivalence, it is remembered in the 'SAFE' that the original pair of 'MOID's is being tested. This is used to force a shortcut to 'WHETHER true' if these 'MOID's should ever be tested again for equivalence lower down the production tree. Since the number of pairs of component 'MOID's that can be derived from any two given 'MOID's is finite, it follows that the testing process terminates.

It remains to be shown that the process is correct. Consider the unrestricted (possibly infinite) production tree that would be obtained if there were no shortcut in the syntax (by omitting the first alternative together with the first member of the other alternative of rule b). If two 'MOID's are not equivalent, then there exists in their mode trees a shortest path from the top node to some node exhibiting a difference. Obviously, the reflection of this shortest path in the unrestricted production tree cannot contain a repeated test for the equivalence of any pair of 'MOID's, and therefore none of the shortcuts to 'WHETHER true' in the restricted production tree can occur on this shortest path. Consequently, the path to the difference must be present also in the (restricted) production tree produced by the syntax. If the testing process does not exhibit a difference in the restricted tree, then no difference can be found in any number of steps: i.e., the 'MOID's are equivalent.}

7.4. Well-formedness

{A mode is well formed if

  1. the elaboration of an actual-declarer specifying that mode is a finite action (i.e., any value of that mode can be stored in a finite memory) and
  2. it is not strongly coercible from itself (since this would lead to ambiguities in coercion).
}

7.4.1. Syntax

a) WHETHER (NOTION) shields SAFE to SAFE {73c} : where (NOTION) is (PLAIN) or (NOTION) is (FLEXETY ROWS of) or (NOTION) is (union of) or (NOTION) is (void), WHETHER true.
b) WHETHER (PREF) shields SAFE to yin SAFE {73c} : WHETHER true.
c) WHETHER (structured with) shields SAFE to yang SAFE {73c} : WHETHER true.
d) WHETHER (procedure with) shields SAFE to yin yang SAFE {73c} : WHETHER true. {As a by-product of mode equivalencing, modes are tested for well-formedness {7.3.1.c}. All nonrecursive modes are well formed. For recursive modes, it is necessary that each cycle in each spelling of that mode (from 'MU definition of MODE' to 'MU application') passes through at least one 'HEAD' which is yin, ensuring condition (i) and one (possibly the same) 'HEAD' which is yang, ensuring condition (ii). Yin 'HEAD's are 'PREF' and 'procedure with'. Yang 'HEAD's are 'structured with' and 'procedure with'. The other 'HEAD's, including 'FLEXETY ROWS of' and 'union of', are neither yin nor yang. This means that the modes specified by A, B and C in

MODE A = STRUCT (INT n, REF A next), B = STRUCT (PROC B next), C = PROC (C) C
are all well formed. However, MODE D = [1 : 10] D, E = UNION (INT, E) is not a mode-declaration.}

{Tao produced the one.
The one produced the two.
The two produced the three.
And the three produced the ten thousand things.
The ten thousand things carry the yin and embrace the yang,
and through the blending of the material force they achieve harmony.
Tao-te Ching, 42, Lao Tzu.}

«Table of contents»

PART IV - Elaboration-independent constructions

8. Denotations

{Denotations, e.g., 3.14 or "abc", are constructs whose yields are independent of any action. In other languages, they are sometimes termed "literals" or "constants".}

8.0.1. Syntax

a) MOID NEST denoter {5D, A341i} : pragment {92a} sequence option, MOID denotation {810a, 811a, 812a, 813a, 814a, 815a, 82a, b, c, 33a, -}.

{The meaning of a denotation is independent of any nest.}

8.1. Plain denotations

{Plain-denotations are those of arithmetic values, truth values, characters and the void value, e.g., 1, 3.14, true, "a" and EMPTY.}

8.1.0.1. Syntax

A) SIZE :: long ; short.
B) *NUMERAL :: fixed point numeral ; variable point numeral ; floating point numeral.
a) SIZE INTREAL denotation {a, 80a} : SIZE symbol {94d} , INTREAL denotation {a, 811a, 812a} .
b) *plain denotation : PLAIN denotation {a, 811a, 812a, 813a, 814a} ; void denotation {815a} .

{Example:  
a) LONG 0 }

8.1.0.2. Semantics

The yield W of an INTREAL-denotation is the "intrinsic value" {8.1.1.2, 8.1.2.2.a, b} of its constituent NUMERAL;
• it is required that W be not greater than the largest value of mode 'INTREAL' that can be distinguished {2.1.3.1.d}.
{An INTREAL-denotation yields an arithmetic value {2.1.3.1.a}, but arithmetic values yielded by different INTREAL-denotations are not necessarily different (e.g., 123.4 and 1.23410+2).}

8.1.1. Integral denotations

8.1.1.1. Syntax

a) integral denotation {80a, 810a} : fixed point numeral {b}.
b) fixed point numeral {a, 812c, d, f, i, A341h} : digit cypher {c} sequence.
c) digit cypher {b} : DIGIT symbol {94b} .

{Examples:  
a) 4096
b) 4096
c) 4 }

8.1.1.2. Semantics

The intrinsic value of a fixed-point-numeral N is the integer of which the reference-language form of N {9.3.b} is a decimal representation.

8.1.2. Real denotations

8.1.2.1. Syntax

a) real denotation {80a, 810a} : variable point numeral {b}; floating point numeral {e}.
b) variable point numeral {a, f} : integral part {c} option, fractional part {d}.
c) integral part {b} : fixed point numeral {811b} .
d) fractional part {b} : point symbol {94b} , fixed point numeral {811b} .
e) floating point numeral {a} : stagnant part {f}, exponent part {g}.
f) stagnant part {e} : fixed point numeral {811b} ; variable point numeral {b}.
g) exponent part {e} : times ten to the power choice {h}, power of ten {i}.
h) times ten to the power choice {g} : times ten to the power symbol {94b} ; letter e symbol {94a} .
i) power of ten {g} : plusminus {j} option, fixed point numeral {811b} .
j) plusminus {i} : plus symbol {94c} ; minus symbol {94c} .

{Examples:
a) 0.00123 • 1.23e-3
b) 0.00123
c) 0
d) .00123
e) 1.23e-3
f) 123 • 1.23
g) e-3
h) 10 • e
i) -3
j) + • -}

8.1.2.2. Semantics

a) The intrinsic value V of a variable-point-numeral N is determined as follows:
• let I be the intrinsic value of the fixed-point-numeral of its constituent integral-part, if any, and be 0 otherwise;
• let F be the intrinsic value of the fixed-point-numeral of its fractional-part P divided by 10 as many times as there are digit-cyphers contained in P;
V is the sum in the sense of numerical analysis of I and F.

b) The intrinsic value V of a floating-point-numeral N is determined as follows:
• let S be the intrinsic value of the NUMERAL of its stagnant-part;
• let E be the intrinsic value of the constituent fixed-point-numeral of its exponent-part;
Case A: The constituent plusminus-option of N contains a minus-symbol:

  • V is the product in the sense of numerical analysis of S and 1/10 raised to the power E;
Case B: The direct descendent of that plusminus-option contains a plus-symbol or is empty:
  • V is the product in the sense of numerical analysis of S and 10 raised to the power E.

8.1.3. Boolean denotations

8.1.3.1. Syntax

a) boolean denotation {80a} : true {94b} symbol ; false {94b} symbol.

{Examples:  
TRUE • FALSE }

8.1.3.2. Semantics

The yield of a boolean-denotation is true (false) if its direct descendent is a true-symbol (false-symbol).

8.1.4. Character denotations

{Character-denotations consist of a string-item between two quote-symbols, e.g., "a". To indicate a quote, a quote-image-symbol (represented by "") is used, e.g., """". Since the syntax nowhere allows character- or string-denotations to follow one another, this causes no ambiguity.}

8.1.4.1. Syntax

a) character denotation {80a} : quote {94b} symbol, string item {b}, quote symbol {94b} .
b) string item {a, 83b} : character glyph {c}; quote image symbol {94b} ; other string item {d}.
c) character glyph {b, 92c} : LETTER symbol {94a} ; DIGIT symbol {94b} ; point symbol {94b} ; open symbol {94f} ; close symbol {94f} ; comma symbol {94b} ; space symbol {94b} ; plus symbol {94c} ; minus symbol {94c} .
d) A production rule may be added for the notion 'other string item' {b, for which no hyper-rule is given in this Report} each of whose alternatives is a symbol {1.1.3.1.f} which is different from any terminal production of 'character glyph' {c} and which is not the 'quote symbol'.

{Examples:  
a) "a"
b) a • "" • ?
c) a • 1 • . • ( • ) •, • . • + • -}

8.1.4.2. Semantics

a) The yield of a character-denotation is the intrinsic value of the symbol descended from its string-item.

b) The intrinsic value of each distinct symbol descended from a string-item is a unique character. {Characters have no inherent meaning, except insofar as some of them are interpreted in particular ways by the transput declarations {10.3}. The character-glyphs, which include all the characters needed for transput, form a minimum set which all implementations {2.2.2.c} are expected to provide.}

8.1.5. Void denotation

{A void-denotation may be used to assign a void value to a UNITED-variable, e.g., UNION ([] REAL, VOID) u := EMPTY.}

8.1.5.1. Syntax

a) void denotation {80a} : empty {94b} symbol.

{Example:  
a) EMPTY }

8.1.5.2. Semantics

The yield of a void-denotation is empty.

8.2. Bits denotations

8.2.1. Syntax

A) RADIX :: radix two ; radix four ; radix eight ; radix sixteen.
a) structured with row of boolean field LENGTH LENGTHETY letter aleph mode denotation {a, 80a} : long {94d} symbol, structured with row of boolean field LENGTHETY letter aleph mode denotation {a, c}.
b) structured with row of boolean field SHORTH SHORTHETY letter aleph mode denotation {b, 80a} : short {94d} symbol, structured with row of boolean field SHORTHETY letter aleph mode denotation {b, c}.
c) structured with row of boolean field letter aleph mode denotation {a, b, 80a} : RADIX {d, e, f, g}, letter r symbol {94a} , RADIX digit {h, i, j, k} sequence.
d) radix two {c, A347b} : digit two {94b} symbol.
e) radix four {c, A347b} : digit four {94b} symbol.
f) radix eight {c, A347b} : digit eight {94b} symbol.
g) radix sixteen {c, A347b} : digit one symbol {94b} , digit six symbol {94b} .
h) radix two digit {c, i} : digit zero symbol {94b} ; digit one symbol {94b} .
i) radix four digit {c, j} : radix two digit {h}; digit two symbol {94b} ; digit three symbol {94b} .
j) radix eight digit {c, k} : radix four digit {i}; digit four symbol {94b} ; digit five symbol {94b} ; digit six symbol {94b} ; digit seven symbol {94b} .
k) radix sixteen digit {c} : radix eight digit {j}; digit eight symbol {94b} ; digit nine symbol {94b} ; letter a symbol {94a} ; letter b symbol {94a} ; letter c symbol {94a} ; letter d symbol {94a} ; letter e symbol {94a} ; letter f symbol {94a} .
l) *bits denotation : BITS denotation {a, b, c}.
{BITS :: structured with row of boolean field SITHETY letter aleph mode.}
m) *radix digit : RADIX digit {h, i, j, k}.

{Examples:  
a) LONG 2r101
b) SHORT 16rffff
c) 8r231 }

8.2.2. Semantics

a) The yield V of a bits-denotation D is determined as follows:
• let W be the intrinsic boolean value {b} of its constituent RADIX-digit-sequence:
• let m be the length of W;
• let n be the value of {l} bits width {10.2.1.j}, where {l} stands for as many times long (short) as there are long-symbols (short-symbols) contained in D;
• it is required that m be not greater than n:
V is a structured value {whose mode is some 'BITS'} whose only field is a multiple value having

  1. a descriptor ( (1, n)) and
  2. n elements, that selected by (i) being false if 1 ≤ i ≤ n - m, and being the (i + m - n)-th truth value of {the sequencer} W otherwise.

b) The intrinsic boolean value of a RADIX-digit-sequence S is the shortest sequence of truth values which, regarded as a binary number (true corresponding to 1 and false to 0), is the same as the intrinsic integral value {c} of S.

c) The intrinsic integral value of a radix-two- (radix-four-, radix-eight-, radix-sixteen-) -digit-sequence S is the integer of which the reference-language form of S {9.3.b} is a binary, (quaternary, octal, hexadecimal) representation, where the representations a, b, c, d, e and f, considered as digits, have values 10, 11, 12, 13, 14 and 15 respectively.

8.3. String denotations

{String-denotations are a convenient way of specifying "strings", i.e., multiple values of mode 'row of character'.
Example:

STRING message := "all is well"
}

8.3.1. Syntax

a) row of character denotation {80a} : quote {94b} symbol, string {b} option, quote symbol {94b} .
b) string {a} : string item {814b} , string item {814b} sequence.
c) *string denotation : row of character denotation {a}.

{Examples:
a) "abc"
b) abc }

8.3.2. Semantics

The yield of a string-denotation D is a multiple value V determined as follows:
• let n be the number of string-items contained in D;
• the descriptor of V is ( (1, n));
• for i = 1, ..., n, the element of V with index (i) is the intrinsic value {8.1.4.2.b} of the i-th constituent symbol of the string of D.

{"a" is a character-denotation, not a string-denotation. However, in all strong positions, e.g., STRING s := "a", it can be rowed to a multiple value {6.6}. Elsewhere, where a multiple value is required, a cast {5.5.1.1.a} may be used, e.g., UNION (CHAR, STRING) cs := STRING ("a").}


«Table of contents»

9. Tokens and symbols

9.1. Tokens

{Tokens {9.1.1.f} are symbols {9.1.1.h} possibly preceded by pragments {9.2.1.a}. Therefore, pragments may appear between symbols wherever the syntax produces a succession of tokens. However, in a few places, the syntax specifically produces symbols rather than tokens, notably within denotations {8}, format-texts {10.3.4.1.1.a} and, of course, within pragments. Therefore, pragments may not occur in these places.}

9.1.1. Syntax

a) CHOICE STYLE start {34a} : where (CHOICE) is (choice using boolean), STYLE if {94f, -} token ; where (CHOICE) is (CASE), STYLE case {94f, -} token.
b) CHOICE STYLE in {34e} : where (CHOICE) is (choice using boolean), STYLE then {94f, -} token ; where (CHOICE) is (CASE), STYLE in {94f, -} token.
c) CHOICE STYLE again {34l} : where (CHOICE) is (choice using boolean), STYLE else if {94f, -} token ; where (CHOICE) is (CASE), STYLE ouse {94f, -} token.
d) CHOICE STYLE out {34l} : where (CHOICE) is (choice using boolean), STYLE else {94f, -} token ; where (CHOICE) is (CASE), STYLE out {94f, -} token.
e) CHOICE STYLE finish {34a} : where (CHOICE) is (choice using boolean), STYLE fi {94f, -} token ; where (CHOICE) is (CASE), STYLE esac {94f, -} token.
f) NOTION token : pragment {92a} sequence option, NOTION symbol {94a, b, c, d, e, f, g, h} .
g) *token : NOTION token {f}.
h) *symbol : NOTION symbol {94a, b, c, d, e, f, g, h} .

9.2. Comments and pragmats

{A source of innocent merriment.
Mikado, W.S.Gilbert.}

{A pragment is a comment or a pragmat. No semantics of pragments is given and therefore the meaning {2.1.4.1.a} of any program is quite unaffected by their presence. It is indeed the intention that comments should be entirely ignored by the implementation, their sole purpose being the enlightenment of the human interpreter of the program.

Pragmats may, on the other hand, convey to the implementation some piece of information affecting some aspect of the meaning of the program which is not defined by this Report, for example:

  • the action to be taken upon overflow {2.1.4.3.h} or if the scope rule is violated (as in 5.2.1.2.b ), e.g., PR overflow check on PR, PR overflow check off PR, PR scope check on PR or PR scope check off PR;
  • the action to be taken upon completion of the compilation process, e.g., PR compile only PR, PR dump PR or PR run PR;
  • that the language to be implemented is some sublanguage or superlanguage of Algol 68, e.g., PR nonrec PR (for a routine-text which may be presumed to be non-recursive);
  • that the compilation may check for the truth, or attempt to prove the correctness, of some assertion, e.g.:
    INT a, b; read ( (a, b)) PR ASSERT a ≥ 0 & b > 0 PR;
    INT q := 0, r := a;
    WHILE r ≥ b PR ASSERT a = b × q + r & 0 < r PR
    DO (q +:= 1, r -:= b) OD
    PR ASSERT a = b × q + r & 0 ≤ r & r < b PR.
    

    They may also be used to convey to the implementation that the source text is to be augmented with some other text, or edited in some way, for example:

  • some previously compiled portion of the particular-program is to be invoked, e.g., PR WITH segment FROM album PR;
  • the source text is continued on some other document, e.g., PR READ FROM another file PR;
  • the end of the source text has been reached, e.g., PR FINISH PR.

The interpretation of pragmats is not defined in this Report, but is left to the discretion of the implementer, who ought, at least, to provide some means whereby all further pragmats may be ignored, for example:

PR pragmats off PR. }

{ PR algol 68 PR 
  BEGIN 
     PROC PR nonrec PR pr = VOID: pr;
     pr
  END PR run PR PR ? PR

Revised Report on the Algorithmic Language Algol 68.}

9.2.1. Syntax

A) PRAGMENT :: pragmat ; comment.
a) pragment {80a, 91f, A341b, h, A348a, b, c, A349a, A34Ab} : PRAGMENT {b}.
b) PRAGMENT {a} : STYLE PRAGMENT symbol {94b, -}, STYLE PRAGMENT item {c} sequence option, STYLE PRAGMENT symbol {94b, -}.
{STYLE :: brief ; bold ; style TALLY.}
c) STYLE PRAGMENT item {b} : character glyph {814c} ; STYLE other PRAGMENT item {d}.
d) A production rule may be added for each notion designated by 'STYLE other PRAGMENT item' {c, for which no hyper-rule is given in this Report} each of whose alternatives is a symbol {1.1.3.1.f}, different from any terminal production of 'character glyph' {8.1.4.1.c}, and such that no terminal production of any 'STYLE other PRAGMENT item' is the corresponding 'STYLE PRAGMENT symbol'. {Thus COMMENT # COMMENT might be a comment, but ¢ ¢ ¢ could not.}

{Examples:  
a) PR list PR ¢ • source program to be listed ¢
c) l • ? }

9.3. Representations

a) A construct in the strict language must be represented in some "representation language" such as the "reference language", which is used in this Report. Other representation languages specially suited to the supposed preference of some human or mechanical interpreter of the language may be termed "publication" or "hardware" languages. {The reference language is intended to be used for the representation of particular-programs and of their descendents. It is, however, also used in Chapter 10 for the definition of the standard environment.}

b) A "construct in a representation language" is obtained from the terminal production T {1.1.3.2.f} of the corresponding construct in the strict language {1.1.3.2.e} by replacing the symbols in T by their representations, as specified in 9.4 below in the case of the reference language.

{Thus, the strict-language particular-program whose terminal production is 'bold begin symbol' 'skip symbol' 'bold end symbol' gives rise to the reference language particular-program BEGIN SKIP END.}

c) An implementation {2.2.2.c} of Algol 68 which uses representations which are sufficiently close to those of the reference language to be recognized without further elucidation, and which does not augment or restrict the available representations other than as provided for below {9.4.a, b, c}, is an "implementation of the reference language".
{E.g., BEGIN, begin, BEGIN, 'begin and 'begin' could all be representations of the bold-begin-symbol in an implementation of the reference language; some combination of holes in a punched card might be a representation of it in some hardware language.}

9.4. The reference language

a) The reference language provides representations for various symbols, including an arbitrarily large number of TAX-symbols {where TAX :: TAG ; TAB ; TAD ; TAM.} . The representations of some of them are specified below {9.4.1}, and to these may be added suitable representations for style-TALLY-letter-ABC-symbols and style-TALLY-monad-symbols and any terminal productions of 'STYLE other PRAGMENT item' {9.2.1.d} and of 'other string item' {8.1.4.1.d}. Representations are not provided for any of these {but they enable individual implementations to make available their full character sets for use as characters, to provide additional or extended alphabets for the construction of TAG- and TAB-symbols, and to provide additional symbols for use as operators} . There is not, however, {and there must not be,} except in representations of the standard-, and other, preludes {10.1.3.Step 6}, any representation of the letter-aleph-symbol or the primal-symbol. {For the remaining TAX-symbols, see 9.4.2 . There are, however, some symbols produced by the syntax, e.g., the brief-pragmat-symbol, for which no representation is provided at all. This does not preclude the representation of such symbols in other representation languages.}

b) Where more than one representation of a symbol is given, any of them may be chosen. Moreover, it is sufficient for an implementation of the reference language to provide only one. Also, it is not necessary to provide a representation of any particular MONAD-symbol or NOMAD-symbol so long as those that are provided are sufficient to represent at least one version {10.1.3.Step 3} of each operator declared in the standard-prelude.
{For certain different symbols, one same or nearly the same representation is given; e.g., the representation ":" is given for the routine-symbol, the colon-symbol and the up-to-symbol and ":" for the label-symbol. It follows uniquely from the syntax which of these four symbols is represented by an occurrence, outside comments, pragmats and string-denotations, of any mark similar to either of those representations. It is also the case that ".." could be used, without ambiguity, for any of them, and such might indeed be necessary in implementations with limited character sets. It may be noted that, for such implementations, no ambiguity would be introduced were " (/" and "/)" to be used as representations of the style-ii-sub-symbol and the style-ii-bus-symbol, respectively.
Also, some of the given representations appear to be composite; e.g., the representation ":=" of the becomes-symbol appears to consist of ":", the representation of the routine-symbol, etc., and "=", the representation of the equals-symbol and of the is-defined-as-symbol. It follows from the syntax that ":=" can occur, outside comments, pragmats and string-denotations, as a representation of the becomes-symbol only (since "=" cannot occur as the representation of a monadic-operator). Similarly, the other given composite representations do not cause ambiguity.}

c) The fact that the representations of the letter-ABC-symbols given {9.4.1.a} are usually spoken of as small letters is not meant to imply that the corresponding capital letters could not serve equally well. {On the other hand, if both a small letter and the corresponding capital letter occur, then one of them is presumably the representation of some style-TALLY-letter-ABC-symbol or of a bold-letter-ABC-symbol. See also 1.1.5.b for the possibility of additional 'ABC's in a variant of the language.}

d) A "typographical display feature" is a blank, or a change to a new line or a new page. Such features, when they appear between the symbols of a construct in the reference language, are of no significance and do not affect the meaning of that construct. However, a blank contained within a string- or character-denotation is one of the representations of the space-symbol {9.4.1.b} rather than a typographical display feature. Where the representation of a symbol in the reference language is composed of several marks {e.g., TO, :=}, those marks form one {indivisible} symbol and, unless the contrary is explicitly stated {9.4.2.2.a, c}, typographical display features may not separate them.

9.4.1. Representations of symbols

 
a) Letter symbols
 
symbol representation
 
letter a symbol {814c, 82k, 942B, A346b} a
letter b symbol {814c, 82k, 942B, A344b} b
letter c symbol {814c, 82k, 942B, A348a} c
letter d symbol {814c, 82k, 942B, A342f} d
letter e symbol {812h, 814c, 82k, 942B, A343e} e
letter f symbol {814c, 82k, 942B, A349a} f
letter g symbol {814c, 942B, A34Aa} g
letter h symbol {814c, 942B} h
letter i symbol {814c, 942B, A345b} i
letter j symbol {814c, 942B} j
letter k symbol {814c, 942B, A341f} k
letter l symbol {814c, 942B, A341f} l
letter m symbol {814c, 942B} m
letter n symbol {814c, 942B, A341h} n
letter o symbol {814c, 942B} o
letter p symbol {814c, 942B, A341f} p
letter q symbol {814c, 942B, A341f} q
letter r symbol {814c, 82c, 942B, A347c} r
letter s symbol {814c, 942B, A341l} s
letter t symbol {814c, 942B} t
letter u symbol {814c, 942B} u
letter v symbol {814c, 942B} v
letter w symbol {814c, 942B} w
letter x symbol {814c, 942B, A341f} x
letter y symbol {814c, 942B, A341f} y
letter z symbol {814c, 942B, A342d} z
 
b) Denotation symbols
 
symbol representation
 
digit zero symbol {811c, 814c, 82h, 942C} 0
digit one symbol {43b, 811c, 814c, 82g, h, 942C} 1
digit two symbol {43b, 811c, 814c, 82d, i, 942C} 2
digit three symbol {43b, 811c, 814c, 82i, 942C} 3
digit four symbol {43b, 811c, 814c, 82e, j, 942C} 4
digit five symbol {43b, 811c, 814c, 82j, 942C} 5
digit six symbol {43b, 811c, 814c, 82g, j, 942C} 6
digit seven symbol {43b, 811c, 814c, 82j, 942C} 7
digit eight symbol {43b, 811c, 814c, 82f, k, 942C} 8
digit nine symbol {43b, 811c, 814c, 82k, 942C} 9
point symbol {812d, 814c, A343d} .
times ten to the power symbol {812h} 10  
true symbol {813a} TRUE
false symbol {813a} FALSE
quote symbol {814a, 83a} "
quote image symbol {814b} ""
space symbol {814c}  .
comma symbol {814c} ,
empty symbol {815a} EMPTY
 
c) Operator symbols
 
symbol representation
 
ampersand symbol {942H} &
differs from symbol {942H} 
is less than symbol {942I} <
is at most symbol {942H} 
is at least symbol {942H} 
is greater than symbol {942I} >
divided by symbol {942I} /
over symbol {942H} ÷
percent symbol {942H} %
not symbol {942H} ¬
tilde symbol {942H} ~
down symbol {942H} 
up symbol {942H} 
plus symbol {812j, 814c, 942H, A342e} +
minus symbol {812j, 814c, 942H, A342e} -
equals symbol {942I} =
times symbol {942I} ×
asterisk symbol {942I} *
assigns to symbol {942J} =:
becomes symbol {44f, 521a, 942J} :=
 
[[Next symbols are defined as operator symbols in the original text of the Revised Report, but have no universal representation in HTML. They are identified here by their bold tags, although for instance the standard prelude defines the TAD "OR" to mean "or". Presumably the only way it matters is that by accepting a bold tag as a operator symbol, one is allowed to write "OR:=", "OR=:" etcetera as TAMs {9421K}, but not for instance "PLUS:="]]
 
or symbol {942H} OR
and symbol {942H} AND
window symbol {942H} ELEM
floor symbol {942H} LWB
ceiling symbol {942H} UPB
plus i times symbol {942H} I
 
d) Declaration symbols
 
symbol representation
 
is defined as symbol {42b, 43b, 44c, 45c} =
long symbol {810a, 82a} LONG
short symbol {810a, 82b} SHORT
reference to symbol {46c} REF
local symbol {523a, b} LOC
heap symbol {523a, b} HEAP
structure symbol {46d} STRUCT
flexible symbol {46g} FLEX
procedure symbol {44b, 46o} PROC
union of symbol {46s} UNION
operator symbol {45a} OP
priority symbol {43a} PRIO
mode symbol {42a} MODE
 
e) Mode standards
 
symbol representation
 
integral symbol {942E} INT
real symbol {942E} REAL
boolean symbol {942E} BOOL
character symbol {942E} CHAR
format symbol {942E} FORMAT
void symbol {942E} VOID
complex symbol {942E} COMPL
bits symbol {942E} BITS
bytes symbol {942E} BYTES
string symbol {942E} STRING
sema symbol {942E} SEMA
file symbol {942E} FILE
channel symbol {942E} CHANNEL
 
f) Syntactic symbols
 
symbol representation
 
bold begin symbol {133d} BEGIN
bold end symbol {133d} END
brief begin symbol {133d, A348b, A34Ab}  (
brief end symbol {133d, A348b, A34Ab} )
and also symbol {133c, 33b, f, 34h, 41a, b,
46e, i, q, t, 532b, 541e, 543b, A348b, A34Ac, d} ,
go on symbol {32b} ;
completion symbol {32b} EXIT
label symbol {32c} :
parallel symbol {33c} PAR
open symbol {814c}  (
close symbol {814c} )
bold if symbol {91a} IF
bold then symbol {91b} THEN
bold else if symbol {91c} ELIF
bold else symbol {91d} ELSE
bold fi symbol {91e} FI
bold case symbol {91a} CASE
bold in symbol {91b} IN
bold ouse symbol {91c} OUSE
bold out symbol {91d} OUT
bold esac symbol {91e} ESAC
brief if symbol {91a}  (
brief then symbol {91b} |
brief else if symbol {91c} |:
brief else symbol {91d} |
brief fi symbol {91e} )
brief case symbol {91a}  (
brief in symbol {91b} |
brief ouse symbol {91c} |:
brief out symbol {91d} |
brief esac symbol {91e} )
colon symbol {34j, k} :
brief sub symbol {133e} [
brief bus symbol {133e} ]
style i sub symbol {133e}  (
style i bus symbol {133e} )
up to symbol {46j, k, l, 532f} :
at symbol {532g} @ AT
is symbol {522b} :=: IS
is not symbol {522b} :≠: :/=: ISNT
nil symbol {524a} ° NIL
of symbol {531a} OF
routine symbol {541a, b} :
bold go to symbol {544b} GOTO
bold go symbol {544b} GO
skip symbol {552a} ~ SKIP
formatter symbol {A341a} $
 
g) Loop symbols
 
symbol representation
 
bold for symbol {35b} FOR
bold from symbol {35d} FROM
bold by symbol {35d} BY
bold to symbol {35d, 544b} TO
bold while symbol {35g} WHILE
bold do symbol {35h} DO
bold od symbol {35h} OD
 
h) Pragment symbols
 
symbol representation
 
brief comment symbol {92b} ¢
bold comment symbol {92b} COMMENT
style i comment symbol {92b} CO
style ii comment symbol {92b} #
bold pragmat symbol {92b} PRAGMAT
style i pragmat symbol {92b} PR

9.4.2. Other TAX symbols

9.4.2.1. Metasyntax

A) TAG {D, F, K, 48a, b, c, d} :: LETTER {B}; TAG LETTER {B}; TAG DIGIT {C}.
B) LETTER {A} :: letter ABC {94a} ; letter aleph {-}; style TALLY letter ABC {-}.
C) DIGIT {A} :: digit zero {94b} ; digit one {94b} ; digit two {94b} ; digit three {94b} ; digit four {94b} ; digit five {94b} ; digit six {94b} ; digit seven {94b} ; digit eight {94b} ; digit nine {94b} .
D) TAB {48a, b} :: bold TAG {A, -}; SIZETY STANDARD {E}.
E) STANDARD {D} :: integral {94e} ; real {94e} ; boolean {94e} ; character {94e} ; format {94e} ; void {94e} ; complex {94e} ; bits {94e} ; bytes {94e} ; string {94e} ; sema {94e} ; file {94e} ; channel {94e} .
F) TAD {48a, b} :: bold TAG {A, -}; DYAD {G} BECOMESETY {J}; DYAD {G} cum NOMAD {I} BECOMESETY {J}.
G) DYAD {F} :: MONAD {H}; NOMAD {I}.
H) MONAD {G, K} :: or {94c} ; and {94c} ; ampersand {94c} ; differs from {94c} ; is at most {94c} ; is at least {94c} ; over {94c} ; percent {94c} ; window {94c} ; floor {94c} ; ceiling {94c} ; plus i times {94c} ; not {94c} ; tilde {94c} ; down {94c} ; up {94c} ; plus {94c} ; minus {94c} ; style TALLY monad {-}.
I) NOMAD {F, G, K} :: is less than {94c} ; is greater than {94c} ; divided by {94c} ; equals {94c} ; times {94c} ; asterisk {94c} .
J) BECOMESETY {F, K} :: cum becomes {94c} ; cum assigns to {94c} ; EMPTY.
K) TAM {48a, b} :: bold TAG {A, -}; MONAD {H} BECOMESETY {J}; MONAD {H} cum NOMAD {I} BECOMESETY {J}.
L) ABC {B} :: a ; b ; c ; d ; e ; f ; g ; h ; i ; j ; k ; l ; m ; n ; o ; p ; q ; r ; s ; t ; u ; v ; w ; x ; y ; z.
M) *DOP :: DYAD {G}; DYAD {G}cum NOMAD {I}.

{The metanotion "ABC" is provided, in addition to the metanotion "ALPHA", in order to facilitate the definition of variants of Algol 68 {1.1.5.b}.}

9.4.2.2. Representation

a) The representation of each TAG-symbol not given above {9.4.1} is composed of marks corresponding, in order, to the 'LETTER's or 'DIGIT's contained in that 'TAG'. These marks may be separated by typographical display features {9.4.d}. The mark corresponding to each 'LETTER' ('DIGIT') is the representation of that LETTER-symbol (DIGIT-symbol). {For example, the representation of a letter-x-digit-one-symbol is x1, which may be written x 1. TAG-symbols are used for identifiers and field-selectors.}

b) The representation, if any, of each bold-TAG-symbol is composed of marks corresponding, in order, to the 'LETTER's or 'DIGIT's contained in that 'TAG' {but with no typographical display features in between}. The mark corresponding to each 'LETTER' ('DIGIT') is similar to the mark representing the corresponding LETTER-symbol (DIGIT-symbol), being, in this Report, the corresponding bold faced letter (digit). {Other methods of indicating the similarity which are recognizable without further elucidation are also acceptable, e.g., person, person, PERSON, 'person and 'person' could all be representations of the bold-letter-p-letter-e-letter-r-letter-s-letter-o-letter-n-symbol.}
However, the representation of a bold-TAG-symbol may not be the same as any representation of any other symbol {; thus there may be a finite number of bold-TAG-symbols which have no representation; e.g., there is no representation for the bold-letter-r-letter-e-letter-a-letter-l-symbol because REAL is a representation of the real-symbol; note that the number of bold-TAG-symbols available is still arbitrarily large}. If, according to the convention used, a given sequence of marks could be either the representation of one bold-TAG-symbol or the concatenation of the representations of two or more other symbols, then it is always to be construed as that one symbol {; the inclusion of a blank can always force the other interpretation; e.g., REFREAL is one symbol, whereas REF REAL must always be two}. {Bold-TAG-symbols are used for mode-indications and for operators.}

c) The representation of each SIZE-SIZETY-STANDARD-symbol is composed of the representation of the corresponding SIZE-symbol, possibly followed by typographical display features, followed by the representation of the corresponding SIZETY-STANDARD-symbol. {For example, the representation of a long-real-symbol is LONG REAL, or perhaps 'long''real' (but not, according to section b above, LONGREAL or 'longreal', for those would be representations of the bold-letter-l-letter-o-letter-n-letter-g-letter-r-letter-e-letter-a-letter-l-symbol). SIZETY-STANDARD-symbols are used for mode-indications.}

d) The representation of each DOP-cum-becomes-symbol (DOP-cum-assigns-to-symbol) is composed of the mark or marks representing the corresponding DOP-symbol followed (without intervening typographical display features) by the marks representing the becomes-symbol (the assigns-to-symbol). {For example, the representation of a plus-cum-becomes-symbol is +:=. DOP-cum-becomes-symbols are used for operators.}

e) The representation of each DYAD-cum-NOMAD-symbol is composed of the mark representing the corresponding DYAD-symbol followed {without intervening typographical display features} by the mark representing the corresponding NOMAD-symbol. {For example, the representation of an over-cum-times-symbol is ÷×. DYAD-cum-NOMAD-symbols are used for operators, but note that NOMAD1-cum-NOMAD2-symbols may be only dyadic-operators.}


«Table of contents»

PART V - Environment and Examples

10. Standard environment

{The "standard environment" encompasses the constituent EXTERNAL-preludes, system-tasks and particular-postludes of a program-text.}

10.1. Program texts

{The programmer is concerned with particular-programs {10.1.1.g}. These are always included in a program-text {10.1.1.a} which also contains the standard-prelude, a library-prelude, which depends upon the implementation, a system-prelude and system-tasks, which correspond to the operating environment, possibly some other particular-programs, one or more particular-preludes (one for each particular-program) and one or more particular-postludes.}

10.1.1. Syntax

A) EXTERNAL :: standard ; library ; system ; particular.
B) STOP :: label letter s letter t letter o letter p.
a) program text : STYLE begin {94f, -} token, new LAYER1 preludes {b}, parallel {94f} token, new LAYER1 tasks {d} PACK, STYLE end {94f, -} token.
b) NEST1 preludes {a} : NEST1 standard prelude with DECS1 {c}, NEST1 library prelude with DECSETY2 {c}, NEST1 system prelude with DECSETY3 {c}, where (NEST1) is (new EMPTY new DECS1 DECSETY2 DECSETY3) .
c) NEST1 EXTERNAL prelude with DECSETY {b,f} : strong void NEST1 series with DECSETY1 {32b} , go on {94f} token where (DECSETY1) is (EMPTY) , EMPTY.
d) NEST1 tasks {a} : NEST1 system task {e} list, and also {94f} token, NEST1 user task {f} PACK list.
e) NEST1 system task {d} : strong void NEST1 unit {32d} .
f) NEST1 user task {d} : NEST2 particular prelude with DECS {c}, NEST2 particular program {g} PACK, go on {94f} token, NEST2 particular prelude {i}, where (NEST2) is (NEST1 new DECS STOP) .
g) NEST2 particular program {f} : NEST2 new LABSETY3 joined label definition of LABSETY3 {h}, strong void NEST2 new LABSETY3 ENCLOSED clause {31a ,33a,c,34a,35a} .
h) NEST joined label definition of LABSETY {g,h} : where (LABSETY) is (EMPTY) , EMPTY; where (LABSETY) is (LAB1 LABSETY1) , NEST label definition of LAB1 {32c} , NEST joined label definition of LABSETY1 {h}.
i) NEST2 particular postlude {f} : strong void NEST2 series with STOP {32b} .

{Examples:  
a) (¢ standard-prelude ¢; ¢ library-prelude ¢; ¢ system-prelude ¢;
      PAR BEGIN ¢ system-task-1 ¢, ¢ system-task-2 ¢,
         (¢ particular-prelude ¢;
            (start: commence: BEGIN SKIP END);
            ¢ particular-postlude ¢) ,
         (¢ another user-task ¢) 
      END) 
b) ¢ standard-prelude (10.2, 10.3) ¢; ¢ library-prelude ¢;
      ¢ system-prelude (10.4.1) ¢;
d) ¢ system-task-1 (10.4.2.a) ¢, ¢ system-task-2 ¢,
      (¢ particular-prelude ¢;
         (start: commence: BEGIN SKIP END);
         ¢ particular-postlude ¢) ,
      (¢ another user-task ¢)       
f) ¢ particular-prelude (10.5.1) ¢;
      (start: commence: BEGIN SKIP END); 
      ¢ particular-postlude (10.5.2) ¢      
g) start: commence: BEGIN SKIP END      
h) start: commence:
i) stop: lock (stand in); lock (stand out); lock (stand back) }

10.1.2. The environment condition

a) A program in the strict language must be akin {1.1.3.2.k} to some program-text whose constituent EXTERNAL-preludes and particular-postludes are as specified in the remainder of this section. {It is convenient to speak of the standard-prelude, the library-prelude, the particular-programs, etc. of a program when discussing those parts of that program which correspond to the constituent standard-prelude, etc. of the corresponding program-text.}

b) The constituent standard-prelude of all program-texts is that standard-prelude whose representation is obtained {10.1.3} from the forms given in sections 10.2 and 10.3.

c) The constituent library-prelude of a program-text is not specified in this Report {but must be specified for each implementation; the syntax of 'program text' ensures that a declaration contained in a library-prelude may not contradict any declaration contained in the standard-prelude} .

d) The constituent system-prelude (system-task-list) of all program-texts is that system-prelude (system-task-list) whose representation is obtained from the forms given in section 10.4 , with the possible addition of other forms not specified in this Report {but to be specified to suit the operating environment of each implementation} .

e) Each constituent particular-prelude (particular-postlude) of all program-texts is that particular-prelude (particular-postlude) whose representation is obtained from the forms given in section 10.5 , with the possible addition of other forms not specified in this Report {but to be specified for each implementation}.

10.1.3. The method of description of the standard environment

A representation of an EXTERNAL-prelude, system-task or particular-postlude is obtained by altering each form in the relevant sections of this chapter in the following steps:

Step 1: If a given form F begins with OP {the operator-symbol} followed by one of the marks P, Q, R or E, then F is replaced by a number of new forms each of which is a copy of F in which that mark {following the OP} is (all other occurrences in F of that mark are) replaced, in each respective new form, by:

Case A: The mark is P:
-, +, «×, *» or / (-, +, * or /);
Case B: The mark is Q:
«MINUSAB, -:=» , «PLUSAB, +:=», «TIMESAB, ×:=, *:=» or «DIVAB, /:=» (-:= , +:= , *:= or /:=);
Case C: The mark is R:
«<, LT» , «≤, LE» , «=, EQ», «≠, /=, NE» , «≥, GE» or «>, GT» (<, , =, , or >);
Case D: The mark is E:
«=, EQ» or «≠, /=, NE» (= or );

Step 2: If, in some form, as possibly made in the step above, ? occurs followed by an INDICATOR (a field-selector) I, then that occurrence of ? is deleted and each INDICATOR (field-selector) akin {1.1.3.2.k} to I contained in any form is replaced by a copy of one same INDICATOR (field-selector) which does not occur elsewhere in the program and Step 2 is taken again;

Step 3: If a given form F, as possibly modified or made in the steps above, begins with OP {the operator-symbol} followed by a chain of TAO-symbols separated by and-also-symbols, the chain being enclosed between « and », then F is replaced by a number of different "versions" of that form each of which is a copy of F in which that chain, together with its enclosing « and », has been replaced by one of those TAO-symbols {; however, an implementation is not obliged to provide more than one such version {9.4.b} } ;

Step 4: If, in a given form, as possibly modified or made in the steps above, there occurs a sequence S of symbols enclosed between « and » and if, in that S, L INT, L REAL, L COMPL, L BITS or L BYTES occurs, then S is replaced by a chain of a sufficient number of sequences separated by and-also-symbols, the n-th of which is a copy of S in which copy each occurrence of L (L, K, S) is replaced by (n - 1) times long (LONG, LENG, SHORTEN) , followed by an and-also-symbol and a further chain of a sufficient number of sequences separated by and-also-symbols, the m-th of which is a copy of S in which copy each occurrence of L (L, K, S) has been replaced by m times short (SHORT, SHORTEN, LENG); the « and » enclosing that S are then deleted;

Step 5: If, in a given form F, as possibly modified or made in the steps above, L INT, (L REAL, L COMPL, L BITS, L BYTES) occurs, then F is replaced by a sequence of a sufficient number of new forms, the n-th of which is a copy of F in which copy each occurrence of L (L, K, S) is replaced by (n - 1) times long (LONG, LENG, SHORTEN) , and each occurrence of long L (LONG L) by n times long (LONG) , followed by a further sequence of a sufficient number of new forms, the m-th of which is a copy of F in which copy each occurrence of L (L, K, S) is replaced by m times short (SHORT, SHORTEN, LENG) , and each occurrence of LONG L (long L) by (m - 1) times SHORT (short);

Step 6: Each occurrence of F (PRIM) in any form, as possibly modified or made in the steps above, is replaced by a representation of a letter-aleph-symbol (primal-symbol) {9.4.a};

Step 7: If a sequence of representations beginning with and ending with C occurs in any form, as possibly modified or made in the steps above, then this sequence, which is termed a "pseudo-comment", is replaced by a representation of a declarer or closed-clause suggested by the sequence;

Step 8: If, in any form, as possibly modified or made in the steps above, a routine-text occurs whose calling involves the manipulation of real numbers, then this routine-text may be replaced by any other routine-text whose calling has approximately the same effect {; the degree of approximation is left undefined in this Report (see also 2.1.3.1.e)};

Step 9: In the case of an EXTERNAL-prelude, a form consisting of a skip-symbol followed by a go-on-symbol {SKIP;} is added at the end.

{The term "sufficient number", as used in Steps 4 and 5 above, implies that no intended particular-program should have a different meaning or fail to be produced by the syntax solely on account of an insufficiency of that number.}

Wherever {in the transput declarations} the representation 10 (\, I) occurs within a character-denotation or string-denotation, it is to be interpreted as the representation of the string-item {8.1.4.1.b} used to indicate "times ten to the power" (an alternative form {, if any,} of "times ten to the power", "plus i times") on external media. {Clearly, these representations have been chosen because of their similarity to those of the times-ten-to-the-power-symbol {9.4.1.b} and the plus-i-times-symbol {9.4.1.c}, but, on media on which these characters are not available, other string-items must be chosen (and the letter-e-symbol and the letter-i-symbol are obvious candidates) .}

{The declarations in this chapter are intended to describe their effect clearly. The effect may very well be obtained by a more efficient method.}

10.2. The standard prelude

{The declarations of the standard-prelude comprise "environment enquiries", which supply information concerning a specific property of the implementation {2.2.2.c}, "standard modes", "standard operators and functions", "synchronization operations" and "transput declarations" (which are given in section 10.3) .}

10.2.1. Environment enquiries

a) INT int lengths = C 1 plus the number of extra lengths of integers {2.1.3.1.d} C; 

b) INT int shorths = C 1 plus the number of extra shorths of integers {2.1.3.1.d} C; 

c) L INT L max int = C the largest L integral value {2.2.2.b}  C; 

d) INT real lengths = C 1 plus the number of extra lengths of real numbers {2.1.3.1.d}  C; 

e) INT real shorths = C 1 plus the number of extra shorths of real numbers {2.1.3.1.d}  C; 

f) L REAL L max real = C the largest L real value {2.2.2.b}  C; 

g) L REAL L small real = C the smallest L real value such that both 
L 1 +  small real > L 1 and 
L 1 -  small real < L 1 {2.2.2.b} C; 

h) INT bits lengths = C 1 plus the number of extra widths {j} of bits C; 

i) INT bits shorths = C 1 plus the number of extra shorths {j} of bits C; 

j) INT L bits width = C the number of elements in L bits; see L BITS {10.2.2.g};  
       this number increases (decreases) with the "size", i.e., the number of 'long's (minus the number of 'short's) 
       of which 'L' is composed, until a certain size is reached, viz., "the number of extra widths" 
       (minus "the number of extra shorths") of bits, after which it is constant C; 

k) INT bytes lengths = C 1 plus the number of extra widths {m} of bytes C; 

l) INT bytes shorths  = C 1 plus the number of extra shorths {m} of bytes C; 

m) INT L bytes width = C the number of elements in L bytes; see L BYTES {10.2.2.h};  
       this number increases (decreases) with the "size", i.e., the number of 'long's (minus the number of 'short's) 
       of which 'L' is composed, until a certain size is reached, viz., "the number of extra widths" 
       (minus "the number of extra shorths") of bytes, after which it is constant C; 

n) OP ABS = (CHAR a) INT: C the integral equivalent {2.1.3.1.g}  of the character 'a' C; 

o) OP REPR = (INT a) CHAR: C that character 'x', if it exists, for which ABS x = a C; 

p) INT max abs char = C the largest integral equivalent {2.1.3.1.g} of a character C; 

q) CHAR null character = C  some character C; 

r) CHAR flip = C the character used to represent 'true' during transput {10.3.3.1.a, 10.3.3.2.a}  C; 

s) CHAR flop = C the character used to represent 'false' during transput C; 

t) CHAR errorchar = C the character used to represent unconvertible arithmetic values {10.3.2.1.b, c, d, e, f} during transput C; 

u) CHAR blank =  " ";  

10.2.2. Standard modes

a) MODE VOID = C an actual-declarer specifying the mode 'void' C; 

b) MODE BOOL = C an actual-declarer specifying the mode 'boolean' C; 

c) MODE L INT = C an actual-declarer specifying the mode 'L integral' C; 

d) MODE L REAL = C an actual-declarer  specifying the mode 'L real' C; 

e)  MODE CHAR = C an actual-declarer specifying the mode 'character'  C; 

f) MODE L COMPL = STRUCT (L REAL re, im); 

g) MODE L BITS = STRUCT ([1 : L bits width] BOOL L F); {See 10.2.1.j} 
      {The field-selector is hidden from the user in order that he may not 
      break open the structure; in particular, he may not subscript the field.} 

h) MODE L BYTES = STRUCT ([1 : L bytes width] CHAR L  F); {See 10.2.1.m}  

i) MODE STRING = FLEX [1 : 0] CHAR;   

10.2.3. Standard operators and functions

10.2.3.0. Standard priorities

a) PRIO MINUSAB = 1, PLUSAB = 1, TIMESAB = 1, DIVAB = 1, OVERAB = 1, MODAB = 1, PLUSTO = 1,
      -:= = 1, +:= = 1, ×:= = 1,  *:= = 1, /:= = 1, ÷:= = 1, %:= = 1, ÷×:= = 1,
      ÷*:= = 1,  %×:= = 1, +=: = 1, 

      OR = 2,

      & = 3, AND = 3, 

      = = 4, EQ = 4, ≠ = 4, /= = 4, NE = 4, 

      < = 5, LT = 5, ≤ = 5, ≤ = 5, LE = 5, ≥ = 5, ≥ = 5, GE = 5, > = 5, GT = 5, 

      - = 6, + = 6, 

      × = 7, * = 7, / = 7, ÷ = 7, % = 7, OVER = 7,
      ÷× = 7,  ÷* = 7, %× = 7, %* = 7, MOD = 7, ELEM = 7, 

      ↑ = 8, ** =  8, ↓ = 8, UP = 8, DOWN = 8, SHL = 8, SHR = 8, 

      LWB = 8, UPB = 8,

      +× = 9, +* = 9, I = 9;

10.2.3.1. Rows and associated operations

a) MODE ? ROWS = C an actual-declarer specifying a mode united from 
      {2.1.3.6.a} a sufficient set of modes each of which begins with 'row' C;  

b) OP LWB = (INT n, ROWS a) INT: C the lower bound in the n-th bound
      pair of the descriptor of the value of 'a', if that bound pair exists C;  

c) OP UPB = (INT n, ROWS a) INT: C the upper bound in the n-th
      bound pair of the descriptor of the value of 'a', if that bound pair exists C;  

d) OP LWB = (ROWS a) INT: 1 LWB a;   

e) OP UPB = (ROWS a) INT: 1 UPB a; 

{The term "sufficient set", as used in a above and also in 10.3.2.2.b and d, implies that no intended particular-program should fail to be produced (nor any unintended particular-program be produced) by the syntax solely on account of an insufficiency of modes in that set.}

10.2.3.2. Operations on boolean operands

a) OP OR = (BOOL b) BOOL: (a | TRUE | b); 

b) OP «&, AND» = (BOOL a, b) BOOL: (a | b | FALSE); 

c) OP «~, ¬, NOT» = (BOOL a) BOOL: (a | FALSE | TRUE); 

d) OP «=, EQ» = (BOOL a, b) BOOL: (a AND b) OR (NOT a AND NOT b); 

e) OP «≠, /=, NE» = (BOOL a, b) BOOL: NOT (a = b);  

f) OP ABS = (BOOL a) INT: (a | 1 | 0);

10.2.3.3. Operations on integral operands

a) OP «<, LT» = (L INT a, b) BOOL: C true if the value of 'a' is smaller than 
      {2.1.3.1.e}  that of 'b' and false otherwise C; 

b) OP «≤, <=, LE» = (L INT a, b) BOOL: NOT (b < a);

c) OP «=, EQ» = (L INT a, b) BOOL: a ≤ b AND  b ≤ a; 

d) OP «≠, /=, NE» = (L INT a, b) BOOL: NOT (a = b); 

e) OP «≥, >=, GE» = (L INT a, b) BOOL: b ≤ a; 

f)  OP «>, GT» = (L INT a, b) BOOL: b < a; 

g) OP - = (L INT a, b) L INT: C the value of 'a'  minus {2.1.3.1.e} that of 'b' C; 

h) OP - = (L INT a) L INT: L 0 - a; 

i) OP + = (L INT a, b) L INT: a - -b; 

j) OP + = (L INT a) L INT: a;  

k) OP ABS = (L INT a) L INT: (a < L 0 | -a | a); 

l) OP «×, *» = (L INT a, b) L INT:
      BEGIN L INT s := L 0, i := ABS b;
         WHILE i ≥ L 1
         DO s := s + a, i := i - L 1 OD;
         (b < L 0 | -s | s) 
      END;

m) OP «÷, %, OVER» = (L INT a, b) L INT:
     IF b ≠ L 0
     THEN L INT q := L 0, r := ABS a;
        WHILE (r := r - ABS b) ≥ L 0 DO q := q + L 1 OD;
        (a < L 0 AND b > L 0 OR a ≥ L 0 AND b < L 0 | -q | q) 
     FI;

n) OP «÷× ÷×, %×, MOD» = (L INT a, i) L INT:
      (L INT r = a - a ÷ b × b; r < 0 | r + ABS b | r); 

o) OP / = (L INT a, b) L  REAL: L  REAL (a) / L  REAL (b); 

p) OP «↑, **, UP» = (L INT a, INT b) L INT:
      (b ≥ 0 | L INT p := L 1; TO b DO p := p × a OD; p); 

q) OP LENG = (L INT a) LONG L  INT: C the long L integral value lengthened
      from {2.1.3.1.e} the value of 'a' C; 

r) OP SHORTEN = (LONG L INT a) L INT: C the L integral value, if it exists,
   which can be lengthened to {2.1.3.1.e} the value of 'a' C; 

s) OP ODD = (L INT a) BOOL: ABS a ÷× L2 = L1; 

t) OP SIGN = (L  INT a) INT:
      (a > L 0 | 1 |: a < L0 | -1 | 0); 

u) OP «+×, +*, I» = (L INT a, b)  L COMPL : (a, b);  

10.2.3.4. Operations on real operands

a) OP «<, LT» = (L  REAL a, b) BOOL: C true if the value of 'a' is smaller 
      than {2.1.3.1.e}  that of 'b' and false otherwise C; 

b) OP «≤, <=, LE» = (L  REAL a, b) BOOL: NOT (b < a);

c) OP «=, EQ» = (L  REAL a, b) BOOL: a ≤ b AND b ≤ a; 

d) OP «≠, /=, NE» = (L  REAL a, b) BOOL: NOT (a = b); 

e) OP «≥,  >=, GE» = (L  REAL a, b) BOOL: b ≤ a; 

f) OP «>, GT» = (L  REAL a, b) BOOL: b < a;

g) OP - = (L  REAL a, b) L  REAL: C the value of 'a' minus {2.1.3.1.e} that of 'b' C; 

h) OP - = (L  REAL a) L  REAL: L 0 - a; 

i) OP + = (L  REAL a, b) L  REAL: a - -b; 

j) OP + = (L  REAL a) L  REAL: a; 

k) OP ABS = (L  REAL a) L  REAL: (a < L 0 | -a | a); 

l) OP «×, *» = (L  REAL a, b) L  REAL: C the value of 'a' times {2.1.3.1.e}  that of 'b' C; 

m) OP / = (L  REAL a, b) L  REAL: C the value of 'a' divided by {2.1.3.1.e} that of 'b' C;

n) OP LENG = (L  REAL a) LONG L  REAL: C the long L real value lengthened
      from {2.1.3.1.e} the value of 'a' C; 

o) OP SHORTEN = (LONG L  REAL a) L  REAL: C if ABS a ≤ S LENG max real, 
      then a L REAL value 'v' such that, for any L  REAL value 'w', ABS (LENG v - a) ≤ ABS (LENG w - a) C; 

p) OP ROUND = (L  REAL a) L INT: C a L  integral value, if one exists, which
      is widenable to {2.1.3.1.e}  a L  REAL value differing by not more 
      than one-half from the value of 'a' C; 

q) OP SIGN = (L REAL a) INT: (a >L 0 | 1 |: a < L 0 | -1 | 0);  

r) OP ENTIER = (L REAL a) L INT:
      BEGIN L INT j := L 0;
         WHILE j < a DO j := j + L1 OD;
         WHILE j > a DO j := j - L1 OD;
         j
      END;

s) OP «+*, +*, I»  = (L  REAL a, b) L COMPL: (a, b);  

10.2.3.5. Operations on arithmetic operands

a) OP P = (L  REAL a, L INT b) L  REAL: a P L  REAL (b); 

b) OP P = (L INT a, L  REAL b) L  REAL: L  REAL (a) P b; 

c)  OP R = (L  REAL a, L INT b) BOOL: a R L  REAL (b); 

d) OP R = (L INT a, L  REAL b) BOOL: L  REAL (a) R b; 

e) OP «+×, +*, I» = (L  REAL a, L INT b) L COMPL: (a, b); 

f)  OP «+×, +*, I» = (L INT a, L  REAL b) L COMPL: (a, b); 

g) OP «↑, **, UP» = (L REAL a, INT b) L REAL: 
      (L REAL p := L 1; TO ABS b DO p := p × a OD; (b ≥ 0 | p | L 1 / p));  

10.2.3.6. Operations on character operands

a) OP R (CHAR a, b) BOOL: ABS a R ABS b; {10.2.1.n}

b) OP + = (CHAR a, b) STRING: (a, b);  

10.2.3.7. Operations on complex operands

a) OP RE = (L COMPL a) L  REAL: re OF a;  

b) OP IM = (L COMPL a) L  REAL: im OF a;  

c) OP ABS = (L COMPL a) L  REAL: L  sqrt (RE a↑ 2 + IM a ↑ 2); 

d) OP ARG = (L COMPL a) L  REAL:
      IF L  REAL re = RE a, im = IM a;
         re ≠ L 0 OR im ≠ L 0
      THEN IF ABS re > ABS im
         THEN L arctan (im / re) + L pi / L 2 ×
            (im < L 0 | SIGN re - 1 | 1 - SIGN re) 
         ELSE - L arctan (re / im) + L pi / L 2 × SIGN im
         FI
      FI;

e) OP CONJ = (L COMPL a) L COMPL: RE a I - IM a; 

f) OP «=, EQ» = (L COMPL a, b) BOOL: RE a = RE b AND IM a = IM b; 

g)  OP «≠, /=, NE» = (L COMPL a, b) BOOL: NOT (a = b); 

h) OP - = (L COMPL a, b) L COMPL: (RE a - RE b) I (IM a - IM b); 

i) OP - = (L COMPL a) L COMPL: -RE a I -IM a; 

j) OP + = (L COMPL a, b) L COMPL: (RE a + RE b) I (IM a + IM b); 

k) OP + = (L COMPL a) L COMPL: a; 

l) OP «×,*» = (L COMPL a, b) L COMPL: 
      (RE a × RE b - IM a × IM b) I (RE a × IM b + IM a × RE b); 

m) OP / = (L COMPL a, b) L COMPL:
      (L  REAL d = RE (b × CONJ b); L COMPL n = a× CONJ b;
      (RE n / d) I (IM n / d));

n) OP LENG = (L COMPL a) LONG L COMPL: LENG RE a I LENG IM a; 

o) OP SHORTEN  = (LONG L COMPL a) L COMPL: SHORTEN RE a I SHORTEN IM a; 

p) OP P = (L COMPL a, L INT b) L COMPL: a P L COMPL (b); 

q) OP P = (L COMPL a, L  REAL b) L COMPL: a P L COMPL (b); 

r) OP P = (L INT a, L COMPL b) L COMPL: L COMPL (a) P b;  

s) OP P = (L  REAL a, L COMPL b) L COMPL: L COMPL (a) P b; 

t) OP «↑,  **, UP» = (L COMPL a, INT b) L COMPL: 
      (L COMPL p := L 1; TO ABS b DO p := p × a OD; (b ≥ 0 | p | L 1 / p)); 

u) OP E = (L COMPL a, L INT b) BOOL: a E L COMPL (b); 

v) OP E = (L COMPL a, L  REAL b) BOOL: a E L COMPL (b); 

w) OP E =  (L INT a, L COMPL b) BOOL: b E a; 

x) OP E = (L  REAL a, L COMPL b) BOOL: b E a;  

10.2.3.8. Bits and associated operations


a) OP «=, EQ» = (L BITS a, b) BOOL:
      BEGIN BOOL c;
         FOR i TO L bits width
         WHILE c := (L F OF a) [i]= (L F OF b) [i]
         DO SKIP OD;
         c
      END;

b) OP «≠, /=, NE» = (L BITS a, b) BOOL: NOT (a = b); 

c) OP OR = (L BITS a, b) L BITS :
      BEGIN L BITS c;
         FOR i TO L bits width
         DO (L F OF c) [i] = (L F OF a) [i] OR (L F OF b) [i] OD;
         c
      END;

d) OP «&, AND» = (L BITS a, b) L BITS :
      BEGIN L BITS c;
         FOR i TO L bits width
         DO (L F OF c) [i]:= (L F OF a) [i] AND (L F OF b) [i] OD;
         c
      END;

e) OP «≤, <=, LE» = (L  BITS a, b) BOOL: (a OR b) = b; 

f) OP «≥,  >=, GE» = (L BITS a, b) BOOL: b ≤ a; 

g) OP «↑ , UP, SHL»= (L BITS a, INT b) L BITS :
      IF ABS b ≤ L bits width
      THEN L BITS c := a;
         TO ABS b
         DO IF b >0 THEN
            FOR i FROM 2 TO L bits width
            DO (L F OF e) [i - 1] := (L F OF c) [i] OD;
            (L F OF c) [L bits width] := FALSE
         ELSE
            FOR i FROM L bits width BY -1 TO 2
            DO (L F OF c) [i] := (L F OF c) [i - 1] OD;
            (L F OF c) [1] := FALSE
         FI OD;
         c
      FI;

h) OP «DOWN, SHR» = (L BITS x, INT n) L BITS: x ↑ -n; 

i) OP ABS = (L BITS a) L INT :
      BEGIN L INT c := L 0;
         FOR i TO L bits width
         DO c := L2 × c + K ABS (L F OF a) [i] OD;
         c
      END;
 
j) OP BIN = (L INT a) L BITS :
      IF a ≥ L 0
      THEN L INT b := a; L BITS c;
         FOR i FROM L bits width BY - 1 TO 1
         DO (L F OF c) [i] := ODD b; b := b % L 2 OD;
         c
      FI;

k) OP ELEM = (INT a, L BITS b) BOOL: (L F OF b) [a];

l) PROC L bits pack = ([] BOOL a) L BITS :
      IF INT n = UPB a[@1];
         n ≤ L bits width
      THEN L BITS c;
         FOR i TO L bits width
         DO (L F OF c) [i] := 
            (i ≤ L bits width - n | FALSE | a[@1][i - L bits width + n ]) 
         OD;
         c
      FI;

m) OP «~, ¬, NOT» = (L BITS a) L BITS :
      BEGIN L BITS c;
         FOR i TO L bits width DO (L F OF c) [i] := NOT (L F OF a) [i] OD;
         c
      END;

n) OP LENG = (L BITS a) LONG L BITS : long L bits pack (a); 

o) OP SHORTEN =  (LONG L BITS a) L BITS: L bits pack ([] BOOL (a) 
      [long L bits width -  L bits width + 1 : ]);  

10.2.3.9. Bytes and associated operations

a) OP R = (L BYTES a, b) BOOL: STRING (a) R STRING (b); 

b) OP ELEM = (INT a, L BYTES b) CHAR: (L F OF b) [a]; 

c) PROC L bytes pack = (STRING a) L BYTES:
      IF INT n = UPB a [@1];
         n ≤ L bytes width
      THEN L BYTES c;
         FOR i TO L bytes width
         DO (L F OF c) [i] := (i ≤ n | a[@1][i] | null character) OD;
         c
      FI;

d) OP LENG = (L BYTES a) LONG L BYTES: long L bytes pack (a); 

e) OP SHORTEN = (LONG L BYTES a) L BYTES: 
      L bytes pack (STRING (a) [ : L bytes width]);

10.2.3.10. Strings and associated operations

a) OP «<, LT» = (STRING a, b) BOOL:
      BEGIN INT m = UPB a[@1], n = UPB b[@1]; INT c := 0;
         FOR i TO (m < n | m | n) 
         WHILE (c := ABS a [@1][i] - ABS b[@1][i]) = 0
         DO SKIP OD;
         (c = 0 | m < n AND n > 0 | c < 0) 
      END;

b) OP «≤, <=, LE» = (STRING a, b) BOOL: NOT (b < a); 

c) OP «=, EQ»  = (STRING a, b) BOOL: a ≤ b AND b ≥ a; 

d)  OP «≠, /=, NE» = (STRING a, b) BOOL: NOT (a = b); 

e) OP «≥, >=, GE» = (STRING a, b) BOOL: b ≤ a; 

f) OP «>, GT» = (STRING a, b) BOOL: b < a; 

g) OP R = (STRING a, CHAR b)  BOOL: a R STRING (b); 

h) OP R = (CHAR a, STRING b) BOOL: STRING (a) R b; 

i) OP + = (STRING a, b) STRING:
      (INT m = (INT la = UPB a[@1]; la < 0 | 0 | la),
           n = (INT lb = UPB b[@1]; lb < 0 | 0 | lb);
       [1 : m + n] CHAR c;
       c[1 : m] := a[@1]; c[m + 1 : m + n] := b[@1]; c
       [[The assignments in the last line have potential bounds errors 
         when UPB a[@1] < 0 or UPB b[@1] < 0 and should read
         (m > 0 | c[1 : m] := a[@1]);  (n > 0 | c[m + 1 : m + n] := b[@1]); c]]
      );

j) OP + = (STRING a, CHAR b) STRING: a  + STRING (b); 

k) OP + = (CHAR a, STRING b)  STRING: STRING (a) + b; 

l) OP «×, *» = (STRING a, INT b) STRING: (STRING c; TO b DO c := c + a OD; c); 

m) OP «×, *» = (INT a, STRING b) STRING: b × a;  

n) OP «×, *» = (CHAR a, INT b)  STRING: STRING (a) × b; 

o) OP «×, *» = (INT a, CHAR b) STRING: b × a;

{The operations defined in a, g and h imply that if ABS "a" < ABS "b", then ""< "a"; "a"< "b"; "aa"< "ab"; "aa" < "ba"; "ab" < "b" and "ab" < "ba".}

10.2.3.11. Operations combined with assignations

a) OP «MINUSAB, -:=» = (REF L INT a, L  INT b) REF L INT: a := a - b; 

b) OP «MINUSAB, -:=» = (REF L  REAL a, L  REAL b) REF L  REAL: a := a - b;  

c) OP «MINUSAB, -:=» = (REF L COMPL a, L COMPL b) REF L COMPL: a := a - b; 

d) OP «PLUSAB, +:=» = (REF L INT a, L INT b) REF L INT: a := a + b; 

e) OP «PLUSAB, +:=» = (REF L  REAL a, L  REAL b) REF L  REAL: a := a + b; 

f) OP «PLUSAB, +:=»  = (REF L COMPL a, L COMPL b) REF L COMPL: a := a + b; 

g) OP «TIMESAB, ×:=, *:=» = (REF L INT a,  L INT b) REF L INT :a := a × b; 

h) OP «TIMESAB, ×:=, *:=» = (REF L  REAL a, L  REAL b) REF L  REAL: a :=  a × b; 

i) OP «TIMESAB, ×:=, *:=» =  (REF L COMPL a, L COMPL b) REF L COMPL: a := a × b; 

j) OP «OVERAB, ÷:=, %:= , %:=» = (REF L INT a, L INT b) REF L INT: a := a ÷ b; 

k) OP «MODAB,  ÷×:=, ÷*:=, %×:=, %*:=» = 
      (REF L INT a, L INT b) REF L INT: a := a ÷× b;  

l) OP «DIVAB, /:=» = (REF L  REAL a, L  REAL b) REF L  REAL :a := a / b; 

m) OP «DIVAB, /:=» = (REF L COMPL a, L COMPL b) REF L COMPL: a := a / b;  

n) OP Q = (REF L  REAL a, L INT b) REF L  REAL: a Q L  REAL (b); 

o) OP Q = (REF L COMPL a, L INT b) REF L COMPL: a Q L COMPL (b); 

p) OP Q = (REF L COMPL a, L  REAL b) REF L COMPL: a Q L COMPL (b); 

q) OP «PLUSAB, +:=» = (REF STRING a, STRING b) REF STRING: a := a + b; 

r) OP «PLUSTO , +=:» = (STRING a, REF STRING b) REF STRING: b := a + b; 

s) OP «PLUSAB, +:=» = (REF STRING a, CHAR b) REF STRING: a +:= STRING (b); 

t) OP «PLUSTO , +=:» = (CHAR a, REF STRING b) REF STRING: STRING (a) +=: b; 

u) OP «TIMESAB, ×:=, *:=» = (REF STRING a, INT b) REF STRING: a := a × b;

10.2.3.12. Standard mathematical constants and functions

a) L  REAL L pi = C a L real value close to π see 
      Math. of Comp. V. 16, 1962, pp. 80-99 C;  

b) PROC L sqrt = (L  REAL x) L  REAL: C if x ≥ L 0, a L real value close to
      the square root of  'x' C; 

c) PROC L exp = (L  REAL x) L  REAL: C a L real value, if one exists, close to 
      the exponential function of 'x' C; 

d) PROC L ln = (L  REAL x) L  REAL: C a L real value, if one exists, close to 
      the natural logarithm of x C; 

e) PROC L cos = (L  REAL x) L  REAL: C a L real value close to the cosine
      of 'x' C;  

f) PROC L arccos = (L  REAL x) L  REAL: C if ABS x ≤ L 1, a L real value close
      to the inverse cosine of 'x', L 0 ≤ L arccos (x) ≤ L pi C; 

g) PROC L sin = (L  REAL x) L  REAL: C a L real value close to the sine of 
      x C;  

h) PROC L arcsin = (L  REAL x) L  REAL: C if ABS x ≤ L 1, a L real value close
      to the inverse sine of 'x', ABS L arcsin (x) ≤ L pi / L 2 C; 

i) PROC L tan = (L  REAL x) L  REAL: C a L real value, if one exists, close to 
      the tangent of 'x' C; 

j) PROC L arctan = (L  REAL x) L  REAL: C a L real value close to the 
      inverse tangent of 'x', ABS L arctan (x) ≤ L pi / L 2 C;  

k) PROC L next random = (REF L INT a) L  REAL: 
      (a := C the next pseudo-random L integral value after 'a' from a 
         uniformly distributed sequence on the interval
        [L 0, maxint] C; 
      C the real value corresponding to 'a' according to some mapping 
         of integral values [L 0, max int] into real values  [L 0, L 1) 
         {i.e., such that 0 ≤ x < 1} such that the sequence of real values
         so produced preserves the properties of pseudo-randomness
         and uniform distribution of the sequence of integral values C); 

10.2.4. Synchronization operations

The elaboration of a parallel-clause P {3.3.1.c} in an environ E is termed a "parallel action". The elaboration of a constituent unit of P in E is termed a "process" of that parallel action.

Any elaboration A {in some environ} of either of the ENCLOSED-clauses delineated by the pragmats {9.2.1.b} PR start of incompatible part PR and PR finish of incompatible part PR in the forms 10.2.4.d and 10.2.4.e is incompatible with {2.1.4.2.e} any elaboration B of either of those ENCLOSED-clauses if A and B are descendent actions {2.1.4.2.b} of different processes of some same parallel action.

a) MODE SEMA = STRUCT (REF INT F); 

b) OP LEVEL = (INT a) SEMA: (SEMA s; F OF s := HEAP INT := a; s); 

c) OP LEVEL = (SEMA a) INT: F OF a;  

d) OP DOWN = (SEMA edsger) VOID:
   BEGIN REF INT dijkstra = F OF edsger;
      WHILE
         PR start of incompatible part PR
            IF dijkstra ≥ 1 THEN dijkstra -:= 1; FALSE
            ELSE
               C let P be the process such that the elaboration
               of this pseudo-comment {10.1.3.Step 7} is a descendent
               action of P, but not of any other process descended 
               from P; the process P is halted {2.1.4.3.f} C;
               TRUE
            FI
         PR finish of incompatible part PR
      DO SKIP OD
   END;

e) OP UP = (SEMA edsger) VOID:
      PR start of incompatible part PR
         IF REF INT dijkstra = F OF edsger; (dijkstra +:= 1) ≥ 1
         THEN
            C all processes are resumed {2.1.4.3.g} which are halted 
            because the integer referred to by the name yielded by
            'dijkstra' was smaller than one C
         FI
      PR finish of incompatible part PR;

10.3. Transput declarations

{"So it does!" said Pooh, "It goes in!"
"So it does!" said Piglet, "And it comes out!"
"Doesn't it? " said Eeyore, "It goes in and out like anything,"
Winnie-the-Pooh, A.A. Milne.}

{Three ways of "transput" (i.e., input and output) are provided by the standard-prelude, viz., formatless transput {10.3.3}, formatted transput {10.3.5} and binary transput {10.3.6}.}

10.3.1. Books, channels and files

{"Books", "channels" and "files" model the transput devices of the physical machine used in the implementation.}

10.3.1.1. Books and backfiles

{aa) All information within the system is to be found in a number of "books". A book {a} is a structured value including a field text of the mode specified by FLEXTEXT {b} which refers to information in the form of characters. The text has a variable number of pages, each of which may have a variable number of lines, each of which may have a variable number of characters. Positions within the text are indicated by a page number, a line number and a character number. The book includes a field lpos which indicates the "logical end" of the book, i.e., the position up to which it has been filled with information, a string idf, which identifies the book and which may possibly include other information, e.g., ownership, and fields putting and users which permit the book to be opened {10.3.1.4.d} on more than one file simultaneously only if putting is not possible on any of them.

bb) The books in the system are accessed via a chain of backfiles. The chain of books available for opening {10.3.1.4.dd} is referenced by chainbfile. A given book may be referenced by more than one backfile on this chain, thus allowing simultaneous access to a single book by more than one process {10.2.4}. However such access can only be for reading a book, since only one process may access a book such that it may be written to {aa}. The chain of books which have been locked {10.3.1.4.o} is referenced by lockedbfile.

cc) Simultaneous access by more than one process to the chain of backfiles is prevented by use of the semaphore bfileprotect, which provides mutual exclusion between such processes.

dd) Books may be created (e.g., by input) or destroyed (e.g., after output) by tasks (e.g., the operating system) in the system-task-list {10.4.2}, such books being then added to or removed from the chain of backfiles.}

a) MODE ? BOOK=
     STRUCT (FLEXTEXT text,
        POS lpos ¢ logical end of book ¢,
        STRING idf ¢ identification ¢,
        BOOL putting ¢ TRUE if the book may be written to ¢,
        INT users ¢ the number of times the book is opened ¢);

b) MODE ? TEXT = REF [] [] [] CHAR, MODE ? FLEXTEXT = REF FLEX [] FLEX [] FLEX [] CHAR;

c) MODE ? POS = STRUCT (INT p, l, c);

d) PRIO ? BEYOND=5,
   OP BEYOND = (POS a, b) BOOL:
      IF p OF a < p OF b THEN FALSE
      ELIF p OF a > p OF b THEN TRUE
      ELIF l OF a < l OF b THEN FALSE
      ELIF l OF a > l OF b THEN TRUE
      ELSE c OF a > c OF b
      FI;

e) MODE ? BFILE = STRUCT (REF BOOK book, REF BFILE next);  

f) REF BFILE ? chainbfile := NIL;  

g) REF BFILE ? lockedbfile := NIL;

h) SEMA ? bfileprotect = (SEMA s; F OF s := PRIM INT := 1; s);

10.3.1.2. Channnels

{aa) A "channel" corresponds to one or more physical devices (e.g., a card reader, a card punch or a line printer, or even to a set up in nuclear physics the results of which are collected by the computer) , or to a filestore maintained by the operating system. A channel is a structured value whose fields are routines returning truth values which determine the available methods of access to a book linked via that channel, Since the methods of access to a book may well depend on the book as well as on the channel (e.g., a certain book may have been trapped so that it may be read, but not written to) , most of these properties depend on both the channel and the book. These properties may be examined by use of the environment enquiries provided for files {10.3.1.3.ff}. Two environment enquiries are provided for channels. These are:

estab possible, which returns true if another file may be "established" {10.3.1.4.cc} on the channel;

standconv, which may be used to obtain the default "conversion key" {bb} for the channel,

bb) A "conversion key" is a value of the mode specified by CONV which is used to convert characters to and from the values as stored in "internal" form and as stored in "external" form in a book. It is a structured value comprising a row of structures, each of which contains a value in internal form and its corresponding external value. The implementation may provide additional conversion keys in its library-prelude.

cc) Three standard channels are provided, with properties as defined below (e,f,g); the implementation may provide additional channels in its library-prelude. The channel number field is provided in order that different channels with otherwise identical possibilities may be distinguished.}

a) MODE CHANNEL =
      STRUCT (PROC (REF BOOK) BOOL ? reset, ? set, ? get, ? put, ? bin, ? compress, ? reidf,
         PROC BOOL ? estab, PROC POS ? max pos,
         PROC (REF BOOK) CONV ? standconv, INT ? channel number);

b) MODE ? CONV = STRUCT ([1: INT (SKIP) ] STRUCT (CHAR internal, external) F);

c) PROC estab possible = (CHANNEL chan) BOOL: estab OF chan;

d) PROC standconv = (CHANNEL chan) PROC (REF BOOK) CONV: standconv OF chan; 

e) CHANNEL stand in channel = C a channel value whose field selected by 
      'get' is a routine which always returns true, and whose other
      fields are some suitable values C;

f) CHANNEL stand out channel = C a channel value whose field selected by 
      'put' is a routine which always returns true, and whose other
      fields are some suitable values C;

g) CHANNEL stand back channel = C a channel value whose fields selected by 
      'set', 'reset', 'get', 'put' and 'bin' are routines which always
      return true, and whose other fields are some suitable values C;

10.3.1.3. Files

{aa) A "file" is the means of communication between a particular-program and a book which has been opened on that file via some channel. It is a structured value which includes a reference to the book to which it has been linked {10.3.1.4.bb} and a separate reference to the text of the book. The file also contains information necessary for the transput routines to work with the book, including its current position cpos in the text, its current "state" {bb}, its current "format" {10.3.4} and the channel on which it has been opened.

    bb) The "state" of a file is determined by five fields:
  • read mood, which is true if the file is being used for input:
  • write mood, which is true if the file is being used for output:
  • char mood, which is true if the file is being used for character transput;
  • bin mood, which is true if the file is being used for binary transput:
  • opened, which is true if the file has been linked to a book.

cc) A file includes some "event routines", which are called when certain conditions arise during transput. After opening a file, the event routines provided by default return false when called, but the programmer may provide other event routines. Since the fields of a file are not directly accessible to the user, the event routines may be changed by use of the "on routines" (l,m,n,o,p,q,r) . The event routines are always given a reference to the file as a parameter. If the elaboration of an event routine is terminated, then the transput routine which called it can take no further action: otherwise, if it returns true, then it is assumed that the condition has been mended in some way, and, if possible, transput continues, but if it returns false, then the system continues with its default action. The on routines are:

on logical file end. The corresponding event routine is called when, during input from a book or as a result of calling set, the logical end of the book is reached (see 10.3.1.6.dd) .

Example: The programmer wishes to count the number of integers on his input tape. The file intape was opened in a surrounding range. If he writes:

BEGIN INT n := 0;
   on logical file end (intape, (REF FILE file) BOOL: GOTO f);
   DO get (intape, LOC INT); n +:= 1 OD;
   f: print (n) 
 END,
then the assignment to the field of intape violates the scope restriction, since the scope of the routine (REF FILE file) BOOL: GOTO f is smaller than the scope of intape, so he has to write:
BEGIN INT n := 0; FILE auxin := intape;
   on logical file end (auxin, (REF FILE file) BOOL: GOTO f);
   DO get (auxin, LOC INT); n +:= 1 OD;
   f: print (n) 
 END.

on physical file end. The corresponding event routine is called when the current page number of the file exceeds the number of pages in the book and further transput is attempted (see 10.3.1.6.dd) ,

on page end. The corresponding event routine is called when the current line number exceeds the number of lines in the current page and further transput is attempted (see 10.3.1.6.dd) .

on line end. The corresponding event routine is called when the current character number of the file exceeds the number of characters in the current line and further transput is attempted (see 10.3.1.6.dd) ,

Example: The programmer wishes automatically to give a heading at the start of each page on his file f:

on page end (f, (REF FILE file) BOOL:
     (put (file, (newpage, "page number ", whole (i +:= 1, 0) ,
         newline)); TRUE) 
         ¢ it is assumed that i has been declared elsewhere ¢) 

on char error. The corresponding event routine is called when a character conversion was unsuccessful or when, during input, a character is read which was not "expected" {10.3.4.1.ll}. The event routine is called with a reference to a character suggested as a replacement. The event routine provided by the programmer may assign some character other than the suggested one. If the event routine returns true, then that suggested character as possibly modified is used,

Example: The programmer wishes to read sums of money punched as "$123.45", " $23.45", " $3.45", etc.:

on char error (stand in, (REF FILE f, REF CHAR sugg) BOOL:
   IF sugg = "0"
   THEN CHAR c; backspace (f); get (f, c);
      (c = "$" | get (f, sugg); TRUE | FALSE) 
   ELSE FALSE
   FI);
INT cents; readf (($3z"."dd$, cents)) 

on value error. The corresponding event routine is called when:

  1. during formatted transput an attempt is made to transput a value under the control of a "picture" with which it is incompatible, or when the number of "frames" is insufficient. If the routine returns true, then the current value and picture are skipped and transput continues; if the routine returns false, then first, on output, the value is output by put, and next undefined is called;
  2. during input it is impossible to convert a string to a value of some given mode (this would occur if, for example, an attempt were made to read an integer larger than max int (10.2.1.c)) .

on format end. The corresponding event routine is called when, during formatted transput, the format is exhausted while some value still remains to be transput. If the routine returns true, then undefined is called if a new format has not been provided for the file by the routine; otherwise, the current format is repeated.

dd) The conv field of a file is its current conversion key (10.3.1.2.bb) . After opening a file, a default conversion key is provided. Some other conversion key may be provided by the programmer by means of a call of make conv {j}. Note that such a key must have been provided in the library-prelude.

ee) The routine make term is used to associate a string with a file. This string is used when inputting a variable number of characters, any of its characters serving as a terminator.

ff) The available methods of access to a book which has been opened on a file may be discovered by calls of the following routines (note that the yield of such a call may be a function of both the book and the channel, and of other environmental factors not defined by this Report):
get possible, which returns true if the file may be used for input;
put possible, which returns true if the file may be used for output;
bin possible, which returns true if the file may be used for binary transput;
compressible, which returns true if lines and pages will be compressed {10.3.1.6.aa} during output, in which case the book is said to be "compressible";
reset possible, which returns true if the file may be reset, i.e., its current position set to (1, 1, 1);
set possible, which returns true if the file may be set, i.e., the current position changed to some specified value; the book is then said to be a "random access" book and, otherwise, a "sequential access" book:
reidf possible, which returns true if the idf field of the book may be changed:
chan, which returns the channel on which the file has been opened {this may be used, for example, by a routine assigned by on physical file end, in order to open another file on the same channel}.

gg) On sequential access books, undefined (10.3.1.4.a) is called if binary and character transput is alternated, i.e., after opening or resetting (10.3.1.6.j) , either is possible but, once one has taken place, the other may not until after another reset.

hh) On sequential access books, output immediately causes the logical end of the book to be moved to the current position (unless both are in the same line); thus input may not follow output without first resetting (10.3.1.6.j) .

Example:

BEGIN FILE f1, t2; [1: 10000] INT x; INT n := 0;
   open (f1, "", channel 2);
   f2 := f1;
      ¢ now f1 and f2 can be used interchangeably ¢
   make conv (f1, flexocode); make conv (f2, telexcode);
      ¢ now f1 and f2 use different codes; flexocode and telexcode are 
      defined in the library-prelude for this implementation ¢
   reset (f1);
      ¢ consequently, f2 is reset too ¢
   on logical file end (f1, (REF FILE f) BOOL: GOTO done);
   FOR i DO get (f1, x [i]); n := i OD;
      ¢ too bad if there are more than 10000 integers in the input ¢
done:   
   reset (f1); FOR i TO n DO put (f2, x [i]) OD;
   close (f2) ¢ f1 is now closed too ¢
END
}

a) MODE FILE =
      STRUCT (REF BOOK ? book, UNION (FLEXTEXT, TEXT) ? text, CHANNEL ? chan,
         REF FORMAT ? format, REF INT ? forp,
         REF BOOL ? read mood, ? write mood, ? char mood, ? bin mood, ? opened,
         REF POS ? cpos ¢ current position ¢,
         STRING ? term ¢ string terminator ¢,
         CONV ? conv ¢ character conversion key ¢,
         PROC (REF FILE) BOOL ? logical file mended, ? physical file mended,
         ? page mended, ? line mended, ? format mended,
         ? value error mended,
         PROC (REF FILE, REF CHAR) BOOL ? char error mended);

b) PROC get possible = (REF FILE f) BOOL:
      (opened OF f | (get OF chan OF f) (book OF f) | undefined; SKIP); 

c) PROC put possible = (REF FILE f) BOOL:
      (opened OF f | (put OF chan OF f) (book OF f) | undefined; SKIP); 

d) PROC bin possible = (REF FILE f) BOOL:
      (opened OF f |  (bin OF chan OF f) (book OF f) | undefined; SKIP); 

e) PROC compressible = (REF FILE f) BOOL:
      (opened OF f | (compress OF chan OF f) (book OF f) | undefined; SKIP); 

f) PROC reset possible = (REF FILE f) BOOL:
      (opened OF f  | (reset OF chan OF f) (book OF f) | undefined; SKIP); 

g) PROC set possible = (REF FILE f) BOOL:
      (opened OF f |  (set OF chan OF f) (book OF f) | undefined; SKIP);

h) PROC reidf possible = (REF FILE f) BOOL:
      (opened OF f  | (reidf OF chan OF f) (book OF f) | undefined; SKIP);

i) PROC chan = (REF FILE f) CHANNEL:
      (opened OF f | chan OF f | undefined; SKIP);

j) PROC make conv = (REF FILE f, PROC (REF BOOK) CONV c) VOID:
      (opened OF f | conv OF f := c (book OF f) | undefined);

k) PROC make term = (REF FILE f, STRING t) VOID: term OF f := t;

l) PROC on logical file end = (REF FILE f, PROC (REF FILE) BOOL p) VOID:
      logical file mended OF f := p; 

m) PROC on physical file end = (REF FILE f, PROC ( REF FILE) BOOL p) VOID:
      physical file mended OF f:= p; 

n) PROC on page end = (REF FILE f, PROC (REF FILE) BOOL p) VOID:
      page mended OF f := p; 

o) PROC on line end = (REF FILE f, PROC (REF FILE) BOOL p) VOID:
      line mended OF f := p; 

p) PROC on format end = (REF FILE f, PROC (REF FILE) BOOL p) VOID:
      format mended OF f := p; 

q) PROC on value error = (REF FILE f, PROC (REF FILE) BOOL p) VOID:
      value error mended OF f := p; 

r) PROC on char error = (REF FILE f, PROC (REF FILE , REF CHAR) BOOL p) VOID: 
      char error mended OF f := p; 

s) PROC reidf = (REF FILE f, STRING idf) VOID:
      IF opened OF f AND reidf possible (f) AND idf ok (idf) 
      THEN idf OF book OF f := idf
      FI;

10.3.1.4. Opening and closing files

{aa) When, during transput, something happens which is left undefined, for example by explicitly calling undefined (a) , this does not imply that the elaboration is catastrophically and immediately interrupted (2.1.4.3.h) , but only that some sensible action is taken which is not or cannot be described by this Report alone and is generally implementation-dependent.

bb) A book is "linked" with a file by means of establish (b) , create (c) or open (d) . The linkage may be terminated by means of close (n), lock (o) or scratch (p) .

cc) When a file is "established" on a channel, then a book is generated {5.2.3} with a text of the given size, the given identification string, with putting set to true, and the logical end of the book at (1, 1, 1) . An implementation may require (g) that the characters forming the identification string should be taken from a limited set and that the string should be limited in length, it may also prevent two books from having the same string. If the establishing is completed successfully, then the value 0 is returned; otherwise, some nonzero integer is returned (the value of this integer might indicate why the file was not established successfully). When a file is "created" on a channel, then a file is established with a book whose text has the default size for the channel and whose identification string is undefined.

dd) When a file is "opened", then the chain of backfiles is searched for the first book which is such that match (h) returns true. (The precise method of matching is not defined by this Report and will, in general, be implementation dependent. For example, the string supplied as parameter to open may include a password of some form.) If the end of the chain of backfiles is reached or if a book has been selected, but putting of the book yields true, or if putting to the book via the channel is possible and the book is already open, then the further elaboration is undefined. If the file is already open, an UP gremlins provides an opportunity for an appropriate system action on the book previously linked (in case no other copy of the file remains to preserve that linkage) .

ee) The routine associate may be used to associate a file with a value of the mode specified by either REF [] CHAR, REF [] [] CHAR or REF [] [] [] CHAR, thus enabling such variables to be used as the book of a file,

ff) When a file is "closed", its book is attached to the chain of backfiles referenced by chainbfile. Some system-task is then activated by means of an UP gremlins. (This may reorganize the chain of backfiles, removing this book, or adding further copies of it. It may also cause the book to be output on some external device.)

gg) When a file is "locked", its book is attached to the chain of backfiles referenced by lockedbfile. Some system-task is then activated by means of an UP gremlins. A book which has been locked cannot be re-opened until some subsequent system-task has re-attached the book to the chain of backfiles available for opening.

hh) When a file is "scratched", some system-task is activated by means of an UP gremlins. (This may cause the book linked to the file to be disposed of in some manner.)}


a) PROC ? undefined = INT: C some sensible system action yielding an 
      integer to indicate what has been done; it is presumed that the 
      system action may depend on a knowledge of any values 
      accessible {2.1.2.c} inside the locale of any environ which is older
      than that in which this pseudo-comment is being elaborated 
      {notwithstanding that no Algol 68 construct written here could
      access those values} C;

b) PROC establish =
      (REF FILE file, STRING idf, CHANNEL chan, INT p, l, c) INT:
      BEGIN
         DOWN bfileprotect;
         PRIM BOOK book :=
            (PRIM FLEX [1 : p] FLEX [1 : l] FLEX [1 : c] CHAR, (1, 1, 1) , idf, TRUE, 1);
         IF file available (chan) AND (put OF chan) (book) 
           AND estab OF chan AND NOT (POS (p, l, c) BEYOND max pos OF chan) 
           AND NOT (POS (1, 1, 1) BEYOND POS (p, l, c)) AND idfok (idf) 
         THEN   
            (opened OF file | UP gremlins | UP bfileprotect);
            file :=
               (book, text OF book, chan, SKIP, SKIP,
                ¢ state: ¢ HEAP BOOL := FALSE, HEAP BOOL := TRUE,
                HEAP BOOL := FALSE, HEAP BOOL := FALSE, HEAP BOOL := TRUE,
                HEAP POS := (1, 1, 1) , "", (standconv OF chan) (book) ,
                ¢ event routines: ¢ false, false, false, false, false, false,  
                (REF FILE f, REF CHAR a) BOOL: FALSE);
            (NOT bin possible (file) | set char mood (file));
            0
         ELSE UP bfileprotect; undefined
         FI
      END;

c) PROC create = (REF FILE file, CHANNEL chan) INT:
      BEGIN POS max pos = max pos OF chan;
         establish (file, SKIP, chan, p OF max pos, l OF max pos, c OF max pos) 
      END;

d) PROC open = (REF FILE file, STRING idf, CHANNEL chan) INT:
      BEGIN
         DOWN bfileprotect;
         IF file available (chan) 
         THEN REF REF BFILE bf := chainbfile; BOOL found := FALSE;
            WHILE (REF BFILE (bf) :≠: NIL) AND NOT found 
            DO
               IF match (idf, chan, book OF bf) 
               THEN found := TRUE
               ELSE bf := next OF bf
               FI
            OD;
            IF NOT found
            THEN UP bfileprotect; undefined
            ELSE REF BOOK book := book OF bf;
               IF putting OF book OR (put OF chan) (book) AND users OF book > 0
               THEN
                   UP bfileprotect; undefined ¢ in this case opening is
                      inhibited by other users - the system may either
                      wait, or yield nonzero (indicating unsuccessful
                      opening) immediately ¢
                ELSE
                   users OF book +:= 1;
                   ((put OF chan) (book) | putting OF book := TRUE);
                   REF REF BFILE (bf) := next OF bf; ¢ remove bfile from chain ¢
                   ( opened OF file | UP gremlins | UP bfileprotect);
                   file :=
                     (book, text OF book, chan, SKIP, SKIP,
                      ¢ state: ¢ HEAP BOOL := FALSE, HEAP BOOL := FALSE,
                      HEAP BOOL := FALSE, HEAP BOOL := FALSE,
                      HEAP BOOL := TRUE,
                      HEAP POS := (1, 1, 1) , "", (standconv OF chan) (book) ,
                      ¢ event routines: ¢ false, false, false, false, false,
                      false, (REF FILE f, REF CHAR a) BOOL: FALSE);
                   (NOT bin possible (file) | set char mood (file));
                   (NOT get possible (file) | set write mood (file));
                   (NOT put possible (file) | set read mood (file));
                   0
                FI
            FI
         ELSE UP bfileprotect; undefined
         FI
      END;

e) PROC associate =
      (REF FILE file, REF [][][] CHAR sss) VOID:
      IF {{ANW - this fails when UPB sss < 1 or UPB sss[1] < 1}}
         INT p = LWB sss; INT l = LWB sss [p]; INT c = LWB sss[p][l];
         p = 1 AND l = 1 AND c = 1
      THEN
         PROC t = (REF BOOK a) BOOL: TRUE;
         PROC f = (REF BOOK a) BOOL: FALSE;
         CHANNEL chan = (t, t, t, t, f, f, f, BOOL: FALSE,
            POS: (max int, max int, max int) , SKIP, SKIP);
         (opened OF file | DOWN bfileprotect; UP gremlins);
         file :=
            (HEAP BOOK := (SKIP, ( UPB sss + 1, 1, 1) , SKIP, TRUE, 1) , sss, chan,
             SKIP, SKIP,
             ¢ state: ¢ HEAP BOOL := FALSE, HEAP BOOL := FALSE,
             HEAP BOOL := TRUE, HEAP BOOL := FALSE, HEAP BOOL := TRUE,
             HEAP POS := (1, 1, 1) , "", SKIP,
             ¢ event routines: ¢ false, false, false, false, false, false,
             (REF FILE f, REF CHAR a) BOOL: FALSE) 
      ELSE undefined
      FI;

f) PROC ? file available = (CHANNEL chan) BOOL: 
      C true if another file, at this instant of time, may be opened on 
         'chan' and false otherwise C;

g) PROC ? idf ok = (STRING idf) BOOL: 
      C true if 'idf' is acceptable to the implementation as the 
         identification of a new book and false otherwise C;

h) PROC ? match = (STRING idf, CHANNEL chan, REF BOOK book name) BOOL: 
      C true if the book referred to by 'book name' may be identified by
         'idf', and if the book may legitimately be accessed through
         'chan', and false otherwise C;

i) PROC ? false = (REF FILE file) BOOL: FALSE
      ¢ this is included for brevity in 'establish', 'open' and 'associate' ¢;  

j) PROC ? set write mood = (REF FILE f) VOID:
      IF NOT put possible (f) OR
         NOT set possible (f) AND bin mood OF f AND read mood OF f
      THEN undefined
      ELSE REF BOOL (read mood OF f) := FALSE; REF BOOL (write mood OF f) := TRUE
      FI;

k) PROC ? set read mood = (REF FILE f) VOID: 
      IF NOT get possible (f) OR
         NOT set possible (f) AND bin mood OF f write mood OF f 
      THEN undefined 
      ELSE REF BOOL (read mood OF f) := TRUE; REF BOOL (write mood OF f) := FALSE 
      FI;

l) PROC ? set char mood = (REF FILE f) VOID: 
      IF NOT set possible (f) AND bin mood OF f 
      THEN undefined 
      ELSE REF BOOL (char mood OF f) := TRUE; REF BOOL (bin mood OF f) := FALSE 
      FI;

m) PROC ? set bin mood = (REF FILE f) VOID: 
      IF NOT bin possible (f) OR NOT set possible (f) AND char mood OF f 
      THEN undefined 
      ELSE REF BOOL (char mood OF f) := FALSE; REF BOOL (bin mood OF f) := TRUE 
      FI;

n) PROC close = (REF FILE file) VOID:
      IF opened OF file 
      THEN
         DOWN bfileprotect;
            REF BOOL (opened OF file) := FALSE;
            REF BOOK book = book OF file;
            putting OF book := FALSE; users OF book -:= 1;
            (text OF file | (FLEXTEXT): chainbfile := 
                PRIM BFILE := (book, chainbfile));
         UP gremlins
      FI;

o) PROC lock (REF FILE file) VOID:
      IF opened OF file
      THEN DOWN bfileprotect;
              REF BOOL (opened OF file) := FALSE;
              REF BOOK book = book OF file;
              putting OF book := FALSE; users OF book -:= 1;
              (text OF file | (FLEXTEXT): lockedbfile := PRIM BFILE = (book, lockedbfile));
           UP gremlins
      FI;

p) PROC scratch = (REF FILE file) VOID:
      IF opened OF file 
      THEN 
         DOWN bfileprotect;
            REF BOOL (opened OF file) := FALSE;
            putting OF book OF file := FALSE;
            users OF book OF file -:= 1;
         UP gremlins
      FI;

10.3.1.5. Position enquiries

{aa) The "current position" of a book opened on a given file is the value referred to by the cpos field of that file. It is advanced by each transput operation in accordance with the number of characters written or read.

If c is the current character number and lb is the length of the current line, then at all times 1 ≤ c ≤ lb + 1. c = 1 implies that the next transput operation will be to the first character of the line and c = lb + 1 implies that the line has overflowed and that the next transput operation will call an event routine. If lb = 0, then the line is empty and is therefore always in the overflowed state. Corresponding restrictions apply to the current line and page numbers. Note that, if the page has overflowed, the current line is empty and, if the book has overflowed, the current page and line are both empty (e).

bb) The user may determine the current position by means of the routines char number, line number and page number (a, b, c) .

cc) If the current position has overflowed the line, page or book, then it is said to be outside the "physical file" (f, g, h) .

dd) If, on reading, the current position is at the logical end, then it is said to be outside the "logical file" (i).}

{Each routine in this section calls undefined if the file is not open on entry.}

a) PROC char number = (REF FILE f) INT: 
      (opened OF f | c OF cpos OF f | undefined); 

b) PROC line number = (REF FILE f) INT:
      (opened OF f | l OF cpos OF f | undefined); 

c) PROC page number = (REF FILE f) INT:
      (opened OF f | p OF cpos OF f | undefined); 

d) PROC ? current pos = (REF FILE f) POS:
      (opened OF f | cpos OF f | undefined; SKIP);

e) PROC ? book bounds = (REF FILE f) POS: 
      BEGIN POS cpos = current pos (f); 
            INT p = p OF cpos, l = l OF cpos; 
            CASE text OF f IN 
               (TEXT t1): 
                   (INT pb = UPB t1; 
                    INT lb = (p ≤ 0 OR p > pb | 0 | UPB t1 [p]); 
                    INT cb =  (l ≤ 0 OR l > lb | 0 | UPB t1[p][l]); 
                    (pb, lb, cb)) , 
               (FLEXTEXT t2): 
                   (INT pb  = UPB t2; 
                    INT lb = (p ≤ 0 OR p > pb | 0 | UPB t2[p]); 
                    INT cb = (l ≤ 0 OR l > lb | 0 | UPB t2[p][l]); 
                    (pb, lb, cb)) 
            ESAC 
      END; 

f) PROC ? line ended = (REF FILE f) BOOL:
      (INT c = c OF current pos (f); c > c OF book bounds (f));

g) PROC ? page ended = (REF FILE f) BOOL:
      (INT l = l OF current pos (f); l > l OF book bounds (f));

h) PROC ? physical file ended = (REF FILE f) BOOL:
      (INT p = p OF current pos (f); p > p OF book bounds (f));

i) PROC ? logical file ended = (REF FILE f) BOOL:
      (lpos OF book OF f BEYOND current pos (f));

10.3.1.6. Layout routines

{aa) A book input from an external medium by some system-task may contain lines and pages not all of the same length. Contrariwise, the lines and pages of a book which has been established (10.3.1.4.cc) are all initially of the size specified by the user. However if, during output to a compressible book (10.3.1.3.ff), newline (newpage) is called with the current position in the same line (page) as the logical end of the book, then that line (the page containing that line) is shortened to the character number (line number) of the logical end. Thus print (("abcde", newline)) could cause the current line to be reduced to 5 characters in length. Note that it is perfectly meaningful for a line to contain no characters and for a page to contain no lines.

Although the effect of a channel whose books are both compressible and of random access (10.3.1.3.ff) is well defined, it is not anticipated that such a combination is likely to occur in actual implementations.

bb) The routines space (a), newline (c) and newpage (d) serve to advance the current position to the next character, line or page, respectively. They do not, however, (except as provided in cc below) alter the contents of the positions skipped over. Thus print (("a", backspace, space)) has a different effect from print (("a", backspace, blank)) .

The current position may be altered also by calls of backspace (b), set char number (k) and, on appropriate channels, of set (i) and reset (j).

cc) The contents of a newly established book are undefined and both its current position and its logical end are at (1, 1, 1) . As output proceeds, it is filled with characters and the logical end is moved forward accordingly. If, during character output with the current position at the logical end of the book, space is called, then a space character is written (similar action being taken in the case of newline and newpage if the book is not compressible) .

A call of set which attempts to leave the current position beyond the logical end results in a call of undefined (a sensible system action might then be to advance the logical end to the current position, or even to the physical end of the book) . There is thus no defined way in which the current position can be made to be beyond the logical end, nor in which any character within the logical file can remain in its initial undefined state.

dd) A reading or writing operation, or a call of space, newline, newpage, set or set char number, may bring the current position outside the physical or logical file (10.3.1.5.cc, dd), but this does not have any immediate consequence. However, before any further transput is attempted, or a further call of space, newline or newpage (but not of set or set char number) is made, the current position must be brought to a "good" position. The file is "good" if, on writing (reading) , the current position is not outside the physical (logical) file (10.3.1.5.cc, dd). The page (line) is "good" if the line number (character number) has not overflowed. The event routine (10.3.1.3.cc) corresponding to on logical file end, on physical file end, on page end or on line end is therefore called as appropriate. Except in the case of formatted transput (which uses check pos, 10.3.3.2.c) , the default action, if the event routine returns false, is to call, respectively, undefined, undefined, newpage or newline. After this (or if true is returned) , if the position is still not good, an event routine (not necessarily the same one) is called again.

ee) The state of the file (10.3.1.3.bb) controls some effects of the layout routines. If the read/write mood is reading, the effect of space, newline and newpage, upon attempting to pass the logical end, is to call the event routine corresponding to on logical file end with default action undefined; if it is writing, the effect is to output spaces (or, in bin mood, to write some undefined character) or to compress the current line or page (see cc) . If the read/write mood is not determined on entry to a layout routine, undefined is called. On exit, the read/write mood present on entry is restored.)

a) PROC space = (REF FILE f) VOID: 
      IF NOT opened OF f THEN undefined 
      ELSE 
         BOOL reading = (read mood OF f | TRUE |: write mood OF f |  FALSE | undefined; SKIP); 
         (NOT get good line (f, reading) | undefined); 
         REF POS cpos = cpos OF f; 
         IF reading THEN c OF cpos +:= 1 
         ELSE IF logical file ended (f) THEN 
                 IF bin mood OF f THEN 
                    (text OF f | (FLEXTEXT t2): t2[p OF cpos] [l OF cpos] [c OF cpos] := SKIP); 
                    c OF pos +:= 1; 
                    lpos OF book OF f := cpos 
                 ELSE put char (f, " ") 
                 FI 
              ELSE c OF cpos +:= 1 
              FI 
         FI 
      FI;

b) PROC backspace = (REF FILE f) VOID: 
      IF NOT opened OF f THEN undefined 
      ELSE REF INT c = c OF cpos OF f; 
         (c>1 | c-:= 1 | undefined)  
      FI;

c) PROC newline = (REF FILE f) VOID: 
      IF NOT opened OF f THEN undefined 
      ELSE BOOL reading = (read mood OF f | TRUE |: write mood OF f |  FALSE | undefined; SKIP);
        (get good page (f, reading) | undefined); 
        REF POS cpos = cpos OF f, lpos = lpos OF book OF f; 
        IF p OF cpos = p OF lpos AND l OF cpos =  l OF lpos 
        THEN c OF cpos := c OF lpos; 
           IF reading THEN newline (f) 
           ELSE 
              IF compressible (f) 
              THEN REF INT pl = p OF lpos, ll = l OF lpos; 
                 FLEXTEXT text = (text OF f | (FLEXTEXT t2): t2); 
                 text [pl] [ll] := text [pl] [ll] [ : c OF lpos -  1] 
              ELSE WHILE NOT line ended (f) DO space (f) OD 
              FI; 
              cpos := lpos := (p OF cpos, l OF cpos + 1, 1) 
           FI 
        ELSE cpos := (p OF cpos, l OF cpos + 1, 1) 
        FI 
      FI; 

d) PROC newpage = (REF FILE f) VOID: 
      IF NOT opened OF f THEN undefined 
      ELSE 
         BOOL reading = (read mood OF f) | TRUE |: write mood OF f |  FALSE | undefined; SKIP); 
         (get good file (f, reading) | undefined); 
         REF POS cpos = cpos OF f, lpos = lpos OF book OF f; 
         IF p OF cpos = p OF lpos 
         THEN cpos := lpos; 
            IF reading THEN newpage (f) 
            ELSE 
               IF compressible (f) AND l OF lpos ≤ l OF book bounds (f) 
               THEN REF INT pl = p OF lpos, ll = l OF lpos; 
                  FLEXTEXT text =  (text OF f | (FLEXTEXT t2): t2); 
                  text[pl] [ll] := text [pl] [ll]t: c OF lpos - 1];  
                  text[pl] := text [pl] [ : (c OF lpos > 1 | ll | ll - 1) ] 
               ELSE WHILE NOT page ended (f) DO newline (f) OD 
               FI; 
               cpos := lpos := (p OF cpos + 1, 1, 1) 
            FI 
         ELSE cpos  := (p OF cpos + 1, 1, 1) 
         FI 
      FI;

{Each of the following 3 routines either returns true, in which case the line, page or file is good (dd), or it returns false, in which case the current position may be outside the logical file or the page number may have overflowed, or it loops until the matter is resolved, or it is terminated by a jump. On exit, the read/write mood is as determined by its reading parameter.}

e) PROC ? get good line = (REF FILE f, BOOL reading) BOOL: 
      BEGIN BOOL not ended; 
         WHILE not ended := get good page (f, reading); 
            line ended (f) AND not ended 
         DO (NOT (line mended OF f) (f) | set mood (f, reading); newline (f)) OD; 
         not ended 
      END;

f) PROC ? get good page = (REF FILE f, BOOL reading) BOOL: 
      BEGIN BOOL not ended; 
         WHILE not ended := get good file (f, reading); 
            page ended (f) AND not ended 
         DO (NOT (page mended OF f) (f) | set mood (f, reading); newpage (f)) OD; 
         not ended 
      END;

g) PROC ? get good file = (REF FILE f, BOOL reading) BOOL:
      BEGIN BOOL not ended := TRUE; 
         WHILE set mood (f, reading); 
            not ended AND (reading | logical file ended | physical file ended) (f) 
         DO not ended := (reading  | logical file mended OF f | physical file mended OF f) (f) 
         OD;
         not ended
      END;

h) PROC ? set mood = (REF FILE f, BOOL reading) VOID:
      (reading | set read mood (f) | set write mood (f));

i) PROC set = (REF FILE f, INT p, l, c) VOID:
      IF NOT opened OF f OR NOT get possible (f) THEN undefined 
      ELSE BOOL reading = (read mood OF f | TRUE  |: write mood OF f | FALSE undefined; SKIP); 
         REF POS cpos = cpos OF f, lpos =  lpos OF book OF f; 
         POS ccpos = cpos; 
         IF (cpos := (p, l, c)) BEYOND lpos 
         THEN cpos := lpos; 
            (NOT (logical file mended OF f) (f) | undefined); 
            set mood (f, reading)  
         ELIF POS bounds = book bounds (f); 
            p < 1 OR p > p OF bounds + 1 
            OR l < 1 OR  l > l OF bounds + 1 
            OR c < 1 OR c > c OF bounds + 1 
         THEN cpos := ccpos; undefined 
         FI 
      FI;

j) PROC reset = (REF FILE f) VOID:
      IF NOT opened OF f OR NOT reset possible (f) THEN undefined
      ELSE
         REF BOOL (read mood OF f) := NOT put possible (f);
         REF BOOL (write mood OF f) := NOT get possible (f);
         REF BOOL (char mood OF f) := NOT bin possible (f);
         REF BOOL (bin mood OF f) := FALSE;
         REF POS (cpos OF f)  := (1, 1, 1)
       [[; DOWN bfileprotect; UP gremlins]]
      FI;

k) PROC set char number = (REF FILE f, INT c) VOID: 
      IF NOT opened OF f THEN undefined 
      ELSE REF REF POS cpos = cpos OF f; 
         WHILE c OF cpos ≠  c 
         DO 
            IF c < 1 OR c > c OF book bounds (f) + 1
            THEN undefined
            ELIF c > c OF cpos
            THEN space (f) 
            ELSE backspace (f) 
            FI
         OD
      FI;

10.3.2. Transput values

10.3.2.1. Conversion routines

{The routines whole, fixed and float are intended to be used with the formatless output routines put, print and write when it is required to have a little extra control over the layout produced. Each of these routines has a width parameter whose absolute value specifies the length of the string to be produced by conversion of the arithmetic value V provided. Each of fixed and float has an after parameter to specify the number of digits required after the decimal point, and an exp parameter in float specifies the width allowed for the exponent. If V cannot be expressed as a string within the given width, even when the value of after, if provided, has been reduced, then a string filled with errorchar (10.2.1.t) is returned instead. Leading zeroes are replaced by spaces and a sign is normally included. The user can, however, specify that a sign is to be included only for negative values by specifying a negative width. If the width specified is zero, then the shortest possible string into which V can be converted, consistently with the other parameters, is returned. The following examples illustrate some of the possibilities:

    print (whole (i, -4)) which might print " 0", " 99", " -99", "9999" or, if i were greater than 9999, "****", where "*" is the yield of errorchar;
    print (whole (i, 4)) which would print " +99" rather than " 99";
    print (whole (i, 0)) which might print "0", "99", "-99", "9999" or "99999";
    print (fixed (x, -6,3)) which might print " 2.718", "27.183" or "271.83" (in which one place after the decimal point has been sacrificed in order to fit the number in);
    print (fixed (x, 0,3)) which might print "2.718", "27.183" or "271.823";
    print (float (x, 9,3,2)) which might print "-2.71810+0", "+2.71810-1", or "+2.7210+11" (in which one place after the decimal point has been sacrificed in order to make room for the unexpectedly large exponent) .}
a) MODE ? NUMBER= UNION («L  REAL», «L INT »);

b) PROC whole = (NUMBER v, INT width) STRING:
      CASE v IN  
         « (L INT x):
            (INT length := ABS width - (x < L 0 OR width > 0 | 1 | 0) ,
            L INT n := ABS x;
            IF width = 0 THEN 
               L INT m := n; length := 0; 
               WHILE m ÷:= 10; length +:= 1; m ≠ L 0
               DO SKIP OD  
            FI;
            STRING s := subwhole (n, length); 
            IF length = 0 OR char in string (errorchar, LOC INT, s) 
            THEN [[undefined;]] ABS width×errorchar
            ELSE (x < L 0 | "-" |:  width > 0 | "+" | "") PLUSTO s; 
                 (width ≠ 0 | (ABS width - UPB s) × " " PLUSTO s);
                 s
            FI) »,  
         « (L  REAL x): fixed (x, width, 0) »
      ESAC;

c) PROC fixed (NUMBER v, INT width, after) STRING:
      CASE v IN
         « (L  REAL x):
            IF INT length := ABS width - (x < L 0 OR width > 0 | 1 | 0);
               after ≥ 0 AND (length > after OR width = 0) 
            THEN L  REAL y = ABS x;
                 IF width = 0
                 THEN length := (after = 0 | 1 | 0);
                    WHILE y + L .5 × L .1 ↑ after ≥ L10.0 ↑ length
                    DO length +:= 1 OD;
                    length +:= (after = 0 | 0 | after +  1) 
                 FI;
                 STRING s := sub fixed (y, length, after);
                 IF NOT char in string (errorchar, LOC INT, s) 
                 THEN (length > UPB s AND y < L 1.0 | "0" PLUSTO s);
               [[above line should read
                 THEN (length > UPB s AND y + L 0.5 + L .1 ^ after < L 1.0 | "0" PLUSTO s);]]
                    (x < L 0 |  "-" |: width > 0 | "+" | "") PLUSTO s;
                    (width ≠ 0 | (ABS width - UPB s) × " "  PLUSTO s);
                    s
                 ELIF after > 0
                 THEN fixed (v, width, after - 1) 
                 ELSE ABS width × errorchar 
                 FI
              ELSE undefined; ABS width × errorchar
            [[above line should read
              ELIF undefined; width = 0 THEN errorchar ELSE ABS width × errorchar]]
              FI»,
         « (L INT x): fixed (L  REAL (x) , width, after) »
         ESAC;

d) PROC float = (NUMBER v, INT width, after, exp) STRING:
      CASE v IN 
         « (L  REAL x):
            IF INT before = ABS width - ABS exp - (after ≠ 0| after + 1| 0) -2;
               SIGN before + SIGN after > 0
            THEN STRING s, L  REAL y := ABS x, INT p := 0;
                 L standardize (y, before, after, p);
                 s :=  fixed (SIGN x × y, SIGN width × (ABS width - ABS exp - 1) , after) + "10" + whole (p, exp);
                [[above line is debated]]
                 IF exp = 0 OR char in string (errorchar, LOC INT, s) 
                 THEN float (x, width, (after ≠ 0 | after - 1 | 0) , (exp > 0 | exp + 1 |  exp - 1)) 
                 ELSE s 
                 FI
            ELSE undefined; ABS width × errorchar
            [[above line should read
              ELIF undefined; width = 0 THEN errorchar ELSE ABS width × errorchar]]
            FI»,
         « (L INT x): float (L  REAL (x) , width, after, exp) »
      ESAC;

e) PROC ? subwhole = (NUMBER v, INT width) STRING: 
         ¢ returns a string of maximum length 'width' containing a 
             decimal representation of the positive integer 'v' ¢
      CASE v IN 
         « (L INT x):
            BEGIN STRING s, L INT n := x;
               WHILE dig char (S (n MOD L 10)) PLUSTO s;
                  n ÷:= L 10; n ≠ L 0
               DO SKIP OD;
               (UPB s > width | width × errorchar | s) 
            END» 
      ESAC;

f) PROC ? subfixed = (NUMBER v, INT width, after) STRING:
         ¢ returns a string of maximum length 'width' containing a 
             rounded decimal representation of the positive real number 
             'v'; if 'after' is greater than zero, this string contains a
             decimal point followed by 'after' digits ¢
      CASE v IN
         « (L  REAL x):
            BEGIN STRING s, INT before := 0;
               L  REAL y := x +  L .5 × L .1 ↑ after;
               PROC choosedig = (REF L  REAL y) CHAR:
                  dig char ((INT c :=  S ENTIER (y ×:= L 10.0); (c > 9 | c := 9);
                  y -:= K c; c));
               WHILE y > L 10.0 ↑ before DO before +:= 1 OD;
               y /:= L 10.0 ↑ before;
               TO before DO s PLUSAB choosedig (y) OD;
               (after > 0 | s PLUSAB ".");
               TO after DO s PLUSAB choosedig (y) OD;
               (UPB s > width | width × errorchar | s) 
            END»
      ESAC;

g) PROC ? L standardize = (REF L  REAL y, INT before, after, REF INT p) VOID: 
         ¢ adjusts the value of 'y' so that it may be transput according 
             to the format $n (before) d.n (after) d$ ; 'p' is set so that 
             y × 10 ↑ p is equal to the original value of 'y' ¢ 
      BEGIN 
         L  REAL g = L 10.0 ↑ before; L  REAL h = g × L .1;
         WHILE y > g DO y ×:= L .1; p +:= 1 OD;
         (y ≠ L 0.0| WHILE y < h DO y ×:= L 10.0; p -:= 1 OD);
         (y + L .5 × L .1  ↑ after ≥ g | y := h; p +:= 1) 
      END;

h) PROC ? dig char = (INT x) CHAR: "0123456789abcdef"[x  + 1];

i) PROC ? string to L int = (STRING s, INT radix, REF L INT i) BOOL:
         ¢ returns true if the absolute value of the result is ≤ L max int ¢
      BEGIN 
         L INT lr = K radix; BOOL safe := TRUE; 
         L INT n := L 0, L INT m = L max int ÷ lr;
         L INT m1 = L max int - m × lr;
         FOR i FROM 2 TO UPB s
         WHILE L INT dig = K char dig (s[i]);
               safe := n < m OR n = m AND dig ≤ m1  
         DO n := n × lr + dig OD;
         IF safe THEN i := (s[l] = "+" | n | -n); TRUE ELSE FALSE FI
      END;

j) PROC ? string to L real = (STRING s, REF L  REAL r) BOOL: 
         ¢ returns true if the absolute value of the result is ≤ max real ¢
      BEGIN
         INT e := UPB s + 1; 
         char in string ("10", e, s);
         INT p := e; char in string (".", p, s); 
         INT j := 1, length = 0, L  REAL x := L 0.0;
         ¢ skip leading zeroes: ¢
         FOR i FROM 2 TO e -1
         WHILE s[i] = "0" OR s[i] = "." OR s[i] = " "
         DO j := i OD;
         FOR i FROM j + 1 TO e - 1 WHILE length < L real width
         DO IF s [i] ≠ "."
            THEN x := x × L 10.0 + K char dig (s[j := i]); length +:= 1
            FI ¢ all significant digits converted ¢
         OD;
         ¢ set preliminary exponent: ¢
         INT exp := (p > j | p - j - 1 | p - j) , expart  := 0;
         ¢ convert exponent part: ¢
         BOOL safe := IF e < UPB s THEN string to int (s[e + 1: ], 10, expart) ELSE TRUE FI;
         ¢ prepare a representation of L max real to compare with the 
            L  REAL value to be delivered: ¢
         L  REAL max stag := L max real, INT max exp := 0;
         L standardize (max stag, length, 0, max exp); exp +:= expart;
         IF NOT safe OR (exp > max exp OR exp = max exp AND x > max stag) 
         THEN FALSE 
         ELSE r := (s[1] = "+" | x | -x) × L 10.0 ↑ exp; TRUE
         FI
      END;

k) PROC ? char dig = (CHAR x) INT:
      (x = " " | 0 | INT i; char in string (x, i, "0123456789abcdef"); i - 1);

l) PROC char in string = (CHAR c, REF INT i, STRING s) BOOL:
      (BOOL found := FALSE;
       FOR k FROM LWB s TO UPB s WHILE NOT found 
       DO (c = s[k] | i := k; found := TRUE) OD;
       found);

m) INT L int width = 
         ¢ the smallest integral value such that 'L max int' may be 
            converted without error using the pattern n (L int width) d ¢
      (INT c := 1;
       WHILE L 10 ↑ (c-1) < L .1 × L maxint DO c +:= 1  OD;
       c);

n) INT L real width = 
         ¢ the smallest integral value such that different strings are 
            produced by conversion of '1.0' and of '1.0 + L small real' using 
            the pattern d.n (L real width - 1) d ¢
      1 - S ENTIER (L ln (L small real) / L ln (L 10));

o) INT L exp width = 
         ¢ the smallest integral value such that 'L max real' may be
            converted without error using the pattern
            d.n (L real width - 1) d e n (L exp width) d ¢
      1 + S ENTIER (L ln (L ln (L max real) /L ln (L 10)) /L ln (L 10));

10.3.2.2. Transput modes

a) MODE ? SIMPLOUT = UNION («L INT» , «L  REAL», «L COMPL», BOOL,
      «L BITS», CHAR, []CHAR);

b) MODE ? OUTTYPE = C an actual-declarer  specifying a mode united from 
      {2.1.3.6.a} a sufficient set of modes none of which is 'void' or 
      contains 'flexible', 'reference to', 'procedure' or 'union of' C;

c) MODE ? SIMPLIN = UNION («REF L INT», «REF L  REAL», «REF L COMPL»,
      REF BOOL, «REF L BITS», REF CHAR, REF [] CHAR, REF STRING);  

d) MODE ? INTYPE = C an actual-declarer specifying a mode united from 
      {2.1.3.6.a} 'reference to flexible row of character' together with a 
      sufficient set of modes each of which is 'reference to' followed by
      a mode which does not contain 'flexible', 'reference to',
      'procedure' or 'union of' C;

{See the remarks after 10.2.3.1 concerning the term "sufficient set".}

10.3.2.3. Straightening

a) OP ? STRAIGHTOUT = (OUTTYPE x) [] SIMPLOUT: 
      C the result of "straightening" 'x' C;  

b) OP ? STRAIGHTIN = (INTYPE x) [] SIMPLIN:
      C the result of straightening 'x' C;  

c) The result of "straightening" a given value V is a multiple value W {of one dimension} obtained as follows:
• it is required that V (if it is a name) be not nil;
• a counter i is set to 0:
V is "traversed" {d} using i
W is composed of, a descriptor ((1, i)) and the elements obtained by traversing V:
• if V is not (is) a name, then the mode of the result is the mode specified by [] SIMPLOUT ([] SIMPLIN) .
d) A value V is "traversed", using a counter i, as follows:
If V is (refers to) a value from whose mode that specified by SIMPLOUT is united,
then

    i is increased by one:
    • the element of W selected by (i) is V:
otherwise,
    Case A: V is (refers to) a multiple value (of one dimension) having a descriptor ((l, u)):
      • for j = l, ..., u, the element (the subname) of V selected by (j) is traversed using i;
    Case B: V is (refers to) a multiple value (of n dimensions, n ≥ 2) whose descriptor is ((l1,u1) , ..., (ln,un)) where n ≥ 2:
      • for j = l1, ... u1, the multiple value selected {2.1.3.4.i} by (the name generated {2.1.3.4.j} by) the trim (j, (l2, u2, 0) , ..., (ln, un, 0)) is traversed using i;
    Case C: V is (refers to) a structured value V1:
      • the fields (the subnames of V referring to the fields) of V1, taken in order, are traversed using i.

10.3.3. Formatless transput

{In formatless transput, the elements of a "data list" are transput, one after the other, via a specified file. Each element of the data list is either a layout routine of the mode specified by PROC (REF FILE) VOID (10.3.1.6) or a value of the mode specified by OUTTYPE (on output) or INTYPE (on input) . On encountering a layout routine in the data list, that routine is called with the specified file as parameter. Other values in the data list are first straightened (10.3.2.3) and the resulting values are then transput via the given file one after the other.

Transput normally takes place at the current position but, if there is no room on the current line (on output) or if a readable value is not present there (on input) , then first, the event routine corresponding to on line end (or, where appropriate, to on page end, on physical file end or on logical file end) is called, and next, if this returns false, the next "good" character position of the book is found, viz., the first character position of the next nonempty line.}

10.3.3.1. Formatless output

{For formatless output, put (a) and print (or write) (10.5.1.d) may be used. Each straightened value V from the data list is output as follows:

aa) If the mode of V is specified by L INT , then first, if there is not enough room for L int width + 2 characters on the remainder of the current line, a good position is found on a subsequent line (see 10.3.3): next, when not at the beginning of a line, a space is given and then V is output as if under the control of the picture n (L int width - 1) z + d.

bb) If the mode of V is specified by L REAL , then first, if there is not enough room for L real width + L exp width + 5 characters on the current line, then a good position is found on a subsequent line: next, when not at the beginning of a line, a space is given and then V is output as if under control of the picture
+d.n (L real width - 1) den (L exp width - 1) z+d.

cc) If the mode of V is specified by L COMPL , then first, if there is not enough room for 2 × (L real width + L exp width) + 11 characters on the current line, then a good position is found on a subsequent line: next, when not at the beginning of a line, a space is given and then V is output as if under control of the picture
+d.n (L real width - 1) den (L exp width - 1) z+d" "i+d.n (L real width - 1) den (L exp width - 1) z+d .

dd) If the mode of V is specified by BOOL, then first, if the current line is full, a good position is found on a subsequent line: next, if V is true (false) , the character yielded by flip (flop) is output (with no intervening space) .

ee) If the mode of V is specified by L BITS , then the elements of the only field of V are output (as in dd) one after the other (with no intervening spaces, and with new lines being taken as required) ,

ff) If the mode of V is specified by CHAR, then first, if the current line is full, a good position is found on a subsequent line: next V is output (with no intervening space) .

gg) If the mode of V is specified by [] CHAR, then the elements of V are output (as in ff) one after the other (with no intervening spaces, and with new lines being taken as required) .}

a) PROC put = (REF FILE f, [] UNION (OUTTYPE, PROC (REF FILE) VOID) x) VOID:
      IF opened OF f THEN
         FOR i TO UPB x
         DO CASE set write mood (f); set char mood (f); x[i] IN
            (PROC (REF FILE) VOID pf): pf (f) ,
            (OUTTYPE ot):
            BEGIN [] SIMPLOUT y = STRAIGHTOUT ot;
                  «PROC L real conv = (L  REAL r) STRING:
                     float (r, L real width + L exp width + 4, 
                        L real width - 1, L  exp width + 1)»;
                  FOR j TO UPB y 
                  DO CASE y[j] IN
                     (UNION (NUMBER, «L COMPL»)  nc):
                        BEGIN STRING s :=
                           CASE nc IN
                              « (L INT k): whole (k, L int width + 1) »,
                              « (L  REAL r): L real conv (r) »,
                              « (L COMPL z): L real conv (RE z) + " I" + L real conv (IM z) »
                           ESAC;
                           REF REF POS cpos = cpos OF f, INT n = UPB s; 
                           WHILE nextpos (f);
                                 (n > c OF book bounds (f) | undefined);
                                 c OF cpos + (c OF cpos = 1  | n | n + 1) > c OF book bounds (f) + 1
                           DO (NOT (line mended OF f) (f) | put (f, newline));
                              set write mood (f) 
                           OD;
                           (c OF cpos ≠ 1 | " " PLUSTO s);
                           FOR k TO UPB s DO put char (f, s[k]) OD
                        END ¢ numeric ¢,
                     (BOOL b): (next pos (f); put char (f, (b | flip | flop))) ,
                     « (L BITS lb):
                        FOR k TO L bits width
                        DO put (f, (L  F OF lb) [k]) OD»,
                     (CHAR k): (nextpos (f); put char (f, k)) ,
                     ([] CHAR ss):
                        FOR k FROM LWB ss TO UPB ss 
                        DO next pos (f); put char (f, ss[k]) OD
                     ESAC
                  OD
            END
            ESAC
         OD
      ELSE undefined
      FI;

b) PROC ? put char = (REF FILE f, CHAR char) VOID:
      IF opened OF f AND NOT line ended (f) 
      THEN REF POS cpos = cpos OF f, lpos = lpos OF book OF f;
         set char mood (f); set write mood (f);
         REF INT p = p OF cpos, l = l OF cpos, c  = c OF cpos;
         CHAR k; BOOL found := FALSE;
         CASE text OF f IN
           (TEXT): (k := char; found := TRUE) ,
           (FLEXTEXT):
              FOR i TO UPB F OF conv OF f WHILE NOT found
              DO STRUCT (CHAR internal, external) key = (F OF conv OF f) [i];
                 (internal OF key = char | k := external OF key; found := TRUE) 
              OD
         ESAC;
         IF found THEN 
            CASE text OF f IN
               (TEXT t1): t1 [p] [l] [c] := k,
               (FLEXTEXT t2): t2[p] [l] [c] := k
            ESAC;
            c +:= 1;
            IF cpos BEYOND lpos THEN lpos :=  cpos
            ELIF NOT set possible (f) AND POS (p OF lpos, l OF lpos, 1) BEYOND cpos
            THEN lpos :=  cpos; 
               (compressible (f) | 
                  C the size of the line and page containing the logical
                     end of the book and of all subsequent lines and
                     pages may be increased {e.g., to the sizes with
                     which the book was originally established 
                     {10.3.1.4.cc} or to the sizes implied by maxpos OF
                     chan OF f} C) 
            FI
         ELSE k := " ";
              IF NOT (char error mended OF f) (f, k) 
              THEN undefined; k := " "
              FI;
              check pos (f); put char (f, k) 
         FI
      ELSE undefined
      FI ¢ write mood is still set ¢ ;

c) PROC ? next pos = (REF FILE f) VOID:
      (NOT get good line (f, read mood OF f) | undefined) 
         ¢ the line is now good {10.3.1.6.dd} and the read/write mood is
         as on entry ¢ ;

10.3.3.2. Formatless input

{For formatless input, get (a) and read (10.5.1.e) may be used. Values from the book are assigned to each straightened name N from the data list as follows:

aa) If the mode of N is specified by REF L INT , then first, the book is searched for the first character that is not a space (finding good positions on subsequent lines as necessary); next, the largest string is read from the book that could be "indited" (10.3.4.1.1.kk) under the control of some picture of the form +n (k1) " "n (k2) dd or n (k2) dd (where k1 and k2 yield arbitrary nonnegative integers): this string is converted to an integer and assigned to N; if the conversion is unsuccessful, the event routine corresponding to on value error is called.

bb) If the mode of N is specified by REF L REAL , then first, the book is searched for the first character that is not a space (finding good positions on subsequent lines as necessary); next, the largest string is read from the book that could be indited under the control of some picture of the form +n (k1) " " n (k2) d or n (k2) d followed by .n (k3) d d or by ds., possibly followed again by e n (k4) " "+n (k5) " " n (k6) d d or by e n (k5) " "n (k6) d d; this string is converted to a real number and assigned to N; if the conversion is unsuccessful, the event routine corresponding to on value error is called.

cc) If the mode of N is specified by REF L COMPL , then first, a real number is input (as in bb) and assigned to the first subname of N; next, the book is searched for the first character that is not a space; next, a character is input and, if it is not "I" or "i", then the event routine corresponding to on char error (10.3.1.3.cc) is called, the suggestion being "I"; finally, a real number is input and assigned to the second subname of N.

dd) If the mode of N is specified by REF BOOL, then first, the book is searched for the first character that is not a space (finding good positions on subsequent lines as necessary); next, a character is read: if this character is the same as that yielded by flip (flop) , then true (false) is assigned to N; otherwise, the event routine corresponding to on char error is called, the suggestion being flop.

ee) If the mode of N is specified by REF L BITS , then input takes place (as in dd) to the subnames of N one after the other (with new lines being taken as required) .

ff) If the mode of N is specified by REF CHAR, then first, if the current line is exhausted, a good position is found on a subsequent line; next, a character is read and assigned to N.

gg) If the mode of N is specified by REF [] CHAR, then input takes place (as in ff) to the subnames of N one after the other (with new lines being taken as required) .

hh) If the mode of N is specified by REF STRING, then characters are read until either

  1. a character is encountered which is contained in the string associated with the file by a call of the routine make term, or
  2. the current line is exhausted, whereupon the event routine corresponding to on line end (or, where appropriate, to on page end, on physical file end or on logical file end) is called; if the event routine moves the current position to a good position (see 10.3.3) , then input of characters is resumed.
The string consisting of the characters read is assigned to N (note that, if the current line has already been exhausted, or if the current position is at the start of an empty line or outside the logical file, then an empty string is assigned to N) .}
a) PROC get = (REF FILE f, [] UNION (INTYPE, PROC (REF FILE) VOID) x) VOID:
      IF opened OF f THEN
      FOR i TO UPB x 
      DO CASE set read mood (f);  set char mood (f); x[i] IN
         (PROC (REF FILE) VOID pf): pf (f) ,
         (INTYPE it) :
         BEGIN
            [] SIMPLIN y = STRAIGHTIN it; CHAR k; BOOL k empty;
            OP ? = (STRING s) BOOL: ¢ true if the next character, if any, in the current line
                                    is contained in 's' (the character is assigned to 'k') 
                                    and false otherwise ¢
               IF k empty AND (line ended (f) OR  logical file ended (f)) 
               THEN FALSE
               ELSE (k empty | get char (f, k));
                  k empty := char in string (k, LOC INT, s) 
               FI;
            OP ? = (CHAR c) BOOL: ? STRING (c);
            PRIO ! = 8;
            OP !  = (STRING s, CHAR c) CHAR: 
                     ¢ expects a character contained in 's'; if the character
                     read is not in 's', the event routine corresponding to
                     'on char error'  is called with the suggestion 'c' ¢
               IF (k empty | check pos (f); get char (f, k));
                  k empty := TRUE;
                  char in string (k, LOC INT, s) 
               THEN k 
               ELSE CHAR sugg := c; 
                  IF (char error mended OF f) (f, sugg) THEN
                     (char in string (sugg, LOC INT, s) | sugg | undefined; c) 
                  ELSE undefined; c
                  FI;
                  set read mood (f) 
                [[above five lines should read
                  CHAR cc = IF (char error mended OF f) (f, sugg) THEN
                    (char in string (sugg, LOC INT, s) | sugg | undefined; c) 
                  ELSE undefined; c
                  FI;
                  set read mood (f); cc]]
               FI;
            OP ! =  (CHAR s, c) CHAR: STRING (s) ! c;
            PROC skip initial spaces = VOID:
               WHILE (k empty |  next pos (f)); ? " " DO SKIP OD;
            PROC skip spaces = VOID: 
               WHILE ? " " DO SKIP OD;
            PROC read dig = STRING:
               (STRING t := "0123456789" ! "0";
                WHILE ? "0123456789" DO t PLUSAB k OD; t);
            PROC read sign = char:
               (CHAR t = (skipspaces; ? "+-" | k | "+");
                skip spaces; t);
            PROC read num = STRING:
               (CHAR t = read sign; t + read dig);
            PROC read real = STRING: 
               (STRING t := read sign;
               (NOT ? "." | t PLUSAB read dig | k empty := FALSE);
               (? "." | t PLUSAB "." + read dig);
               (? "10\e" | t PLUSAB "10" + read num); t);

            FOR j TO UPB y 
            DO BOOL incomp := FALSE;  k empty := TRUE;
               CASE y[j] IN 
               « (REF L INT ii) :
                  (skip initial spaces;
                     incomp  := NOT string to L int (read num, 10, ii)) »,
               « (REF L  REAL rr) :
                  (skip initial spaces; 
                     incomp := NOT string to L real (read real, rr)) »,
               « (REF L COMPL zz) :
                  (skip initial spaces;
                     incomp := NOT string to L real (read real, re OF zz);
                     skip spaces; "iI" ! "I;";
                     incomp := incomp OR string to L real (read real, im OF zz)) »
               (REF BOOL bb) :
                    (skip initial spaces;
                     bb := (flip + flop) ! flop = flip) ,
               « (REF L BITS lb) :
                  FOR i TO L bits width
                  DO get (f, (L F OF lb) [i]) OD»,
               (REF CHAR cc): (next pos (f); get char (f, cc)) ,
               (REF []CHAR ss) :
                  FOR i FROM LWB ss TO UPB ss
                  DO next pos (f); get char (f, ss [i]) OD,
               (REF STRING ss): 
                  BEGIN STRING t;
                     WHILE check pos (f);
                        IF line ended (f) OR logical file ended (f) 
                        THEN FALSE
                        ELSE get char (f, k);
                             k empty := NOT char in string (k, LOC INT, term OF f) 
                        FI
                     DO t PLUSAB k OD;
                     ss := t 
                  END
               ESAC; 
               (NOT k empty | backspace (f));
               IF incomp 
               THEN (NOT (value error mended OF f) (f) | undefined);
                  set read mood (f) 
               FI
            OD 
         END 
         ESAC 
      OD      
      ELSE undefined 
      FI; 

b) PROC ? get char = (REF FILE f, REF CHAR char) VOID:
      IF opened OF f AND NOT line ended (f) AND NOT logical file ended (f) 
      THEN REF POS cpos = cpos OF f;
         set char mood (f); set read mood (f);
         INT p = p OF cpos, l = l OF cpos, c = c OF cpos;
         c OF cpos +:= 1;
         char := CASE text OF f IN
            (TEXT t1): t1[p][l][c],
            (FLEXTEXT t2) :
               (CHAR k := t2[p][l][c];
                BOOL found := FALSE;
                FOR i TO UPB F OF conv OF f WHILE NOT found
                DO STRUCT (CHAR internal, external) key = (F OF conv OF f) [i];
                  (external OF key = k | k := internal OF key; found := TRUE) 
                OD;
                IF found THEN k
                ELSE k:= " ";
                     IF (char error mended OF f) (f, k) 
                     THEN k
                     ELSE undefined; " "
                     FI; set read mood (f);
                FI) 
            ESAC
      ELSE undefined
      FI ¢ read mood is still set ¢ ;

c) PROC ? check pos = (REF FILE f) VOID:
      BEGIN BOOL reading = read mood OF f;
          BOOL not ended := TRUE;
          WHILE not ended := not ended AND get good page (f, reading);
                line ended (f) AND not ended
          DO not ended := (line mended OF f) (f) OD
      END;

{The routine check pos is used in formatted transput before each call of put char or get char. If the position is not good (10.3.1.6.dd), it calls the appropriate event routine, and may call further event routines if true is returned. If the event routine corresponding to on page end returns false, newpage is called but, if any other event routine returns false, no default action is taken and no more event routines are called. On exit, the read/write mood is as on entry, but the current position may not be good, in which case undefined will be called in the following put char or get char. However, check pos is also called when getting strings (hh), in which case the string is then terminated if the current position is not good.}

10.3.4. Format texts

{In formatted transput, each straightened value from a data list (cf. 10.3.3) is matched against a constituent picture of a format-text provided by the user. A picture specifies how a value is to be converted to or from a sequence of characters and prescribes the layout of those characters in the book. Features which may be specified include the number of digits, the position of the decimal point and of the sign, if any, suppression of zeroes and the insertion of arbitrary strings. For example, using the picture -d.3d " " 3d " " e z+d, the value 1234.567 would be transput as the string " 1.234 56710+3".

A "format" is a structured value (i.e., an internal object) of mode 'FORMAT', which mirrors the hierarchical structure of a format-text (which is an external object) . In this section are given the syntax of format-texts and the semantics for obtaining their corresponding formats. The actual formatted transput is performed by the routines given in section 10.3.5 but, for convenience, a description of their operation is given here, in association with the corresponding syntax.}

10.3.4.1. Collections and pictures

10.3.4.1.1. Syntax

{The following mode-declarations (taken from 10.3.5.a) are reflected in the metaproduction rules A to K below.

A) MODE FORMAT = STRUCT (FLEX [1 : 0] PIECE F);

B) MODE PIECE = STRUCT (INT cp, count, bp, FLEX [1: 0] COLLECTION c);

C) MODE COLLECTION =UNION (PICTURE, COLLITEM);

D) MODE COLLITEM = STRUCT (INSERTION i1, PROC INT rep, INT p, INSERTION i2);

E) MODE INSERTION = FLEX [1 : 0] STRUCT (PROC INT rep, UNION (STRING, CHAR) sa);

F) MODE PICTURE = STRUCT (UNION (PATTERN, CPATTERN, FPATTERN, GPATTERN, VOID) p, INSERTION i);

G) MODE PATTERN = STRUCT (INT type, FLEX [1 : 0] FRAME frames);

H) MODE FRAME = STRUCT (INSERTION i, PROC INT rep, BOOL supp, CHAR marker);

I) MODE CPATTERN = STRUCT (INSERTION i, INT type, FLEX  [1 : 0] INSERTION c);

J) MODE FPATTERN = STRUCT (INSERTION i, PROC FORMAT pf);

K) MODE GPATTERN = STRUCT (INSERTION i, FLEX [1 : 0]  PROC INT spec);} 

A) FORMAT :: structured with row of PIECE field letter aleph mode.
B) PIECE :: structured with integral field letter c letter p integral field letter c letter o letter u letter n letter t integral field letter b letter p row of COLLECTION field letter c mode.
C) COLLECTION :: union of PICTURE COLLITEM mode.
D) COLLITEM :: structured with INSERTION field letter i digit one procedure yielding integral field letter r letter e letter p integral field letter p INSERTION field letter i digit two mode.
E) INSERTION :: row of structured with procedure yielding integral field letter r letter e letter p union of row of character character mode field letter s letter a mode.
F) PICTURE :: structured with union of PATTERN CPATTERN FPATTERN GPATTERN void mode field letter p INSERTION field letter i mode.
G) PATTERN :: structured with integral field letter t letter y letter p letter e row of FRAME field letter f letter r letter a letter m letter e letter s mode.
H) FRAME :: structured with INSERTION field letter i procedure yielding integral field letter r letter e letter p boolean field letter s letter u letter p letter p character field letter m letter a letter r letter k letter e letter r mode.
I) CPATTERN :: structured with INSERTION field letter i integral field letter t letter y letter p letter e row of INSERTION field letter c mode.
J) FPATTERN :: structured with INSERTION field letter i procedure yielding FIVMAT field letter p letter f mode.
K) GPATTERN :: structured with INSERTION field letter i row of procedure yielding integral field letter s letter p letter e letter c mode.
L) FIVMAT :: mui definition of structured with row of structured with integral field letter c letter p integral field letter c letter o letter u letter n letter t integral field letter b letter p row of union of structured with union of PATTERN CPATTERN structured with INSERTION field letter i procedure yielding mui application field letter p letter f mode GPATTERN void mode field letter p INSERTION field letter i mode COLLITEM mode field letter c mode field letter aleph mode. {'FIVMAT' is equivalent (2.1.1.2.a) to 'FORMAT'.}
M) MARK :: sign ; point ; exponent ; complex ; boolean.
N) COMARK :: zero ; digit ; character.
O) UNSUPPRESSETY :: unsuppressible ; EMPTY.
P) TYPE :: integral ; real ; boolean ; complex ; string ; bits ; integral choice ; boolean choice ; format ; general.
a) FORMAT NEST format text {5D} : formatter {94f} token, NEST collection {b} list, formatter {94f} token.
b) NEST collection {a,b} : pragment {92a} sequence option, NEST picture {c}; pragment {92a} sequence option, NEST insertion {d}, NEST replicator {g}, NEST collection {b} list brief pack, pragment {92a} sequence option, NEST insertion {d}.
c) NEST picture {b} : NEST TYPE pattern {A342a ,A343a,A344a,A345a,A346a,A347a,A348a,b,A349a,A34Aa} option, NEST insertion {d}.
d) NEST insertion {b,c,j,k,A347b ,A343a,b,A349a,A34Aa} : NEST literal {i} option, NEST alignment {e} sequence option.
e) NEST alignment {d} : NEST replicator {g}, alignment code {f}, NEST literal {i} option.
f) alignment code {e} : letter k {94a} symbol ; letter x {94a} symbol ; letter y {94a} symbol ; letter l {94a} symbol ; letter p {94a} symbol ; letter q {94a} symbol.
g) NEST replicator {b,e,i,k} : NEST unsuppressible replicator {h} option.
h) NEST unsuppressible replicator {g,i} : fixed point numeral {811b} ; letter n {94a} symbol, meek integral NEST ENCLOSED clause {31a ,34a,-}, pragment {92a} sequence option.
i) NEST UNSUPPRESSETY literal {d,e,i,A348c} : NEST UNSUPPRESSETY replicator {g,h}, strong row of character NEST denoter {80a} coercee {61a} , NEST unsuppressible literal {i} option.
j) NEST UNSUPPRESSETY MARK frame {A342c ,A343b,c,A344a,A345a} : NEST insertion {d}, UNSUPPRESSETY suppression {l}, MARK marker {A342e ,A343d,e,A344b,A345b} .
k) NEST UNSUPPRESSETY COMARK frame {A342b,c ,A346a} : NEST insertion {d}, NEST replicator {g}, UNSUPPRESSETY suppression {l}, COMARK marker {A342d,f ,A346b} .
l) UNSUPPRESSETY suppression {j,k,A347b} : where (UNSUPPRESSETY) is (unsuppressible) , EMPTY ; where (UNSUPPRESSETY) is (EMPTY) , letter s {94a} symbol option.
m) *frame : NEST UNSUPPRESSETY MARK frame {j}; NEST UNSUPPRESSETY COMARK frame {k}; NEST RADIX frame {A347b} .
n) *marker : MARK marker {A342e ,A343d,e,A344b,A345b} ; COMARK marker {A342d,f ,A346b} ; radix marker {A347c} .
o) *pattern : NEST TYPE pattern {A342a ,A343a,A344a,A345a,A346a,A347a,A348a,h,A349a,A34Aa} .

{Examples:  
a) $p "table of"x 10a,l n (lim-1) ("x=" 12z+d 2x, +.12de+2d 3q"+j×"3" "si+.10de+2d l) p$    
b) p"table of"x10a • l n (lim - 1) ("x=" 12z+d 2x, +.12de+2d 3q"+j×"3" "si+.10de+2d l) p      
c) 120k c("mon", "tues", "wednes", "thurs", "fri", "satur", "sun") "day"
d) p"table of"x
e) p"table of"      
h) 10 • n (lim -1)     
i) "+j×"3" "     
j) si      
k) "x="12z     
l) s }

{The positions where pragments {9.2.1.a} may occur in format-texts are restricted. In general (as elsewhere in the language) , a pragment may not occur between two DIGIT- or LETTER-symbols.}

{aa) For formatted output, putf {10.3.5.1.a} and printf (or writef) {10.5.1.f} may be used and, for formatted input, getf {10.3.5.2.a} and readf {10.5.1.g}. Each element in the data list (cf. 10.3.3) is either a format to be associated with the file or a value to be transput (thus a format may be included in the data list immediately before the values to be transput using that format) .

bb) During a call of putf or getf transput proceeds as follows: For each element of the data list, considered in turn,

    If it is a format,
    then it is made to be the current format of the file by associate format (10.3.5.k):
    otherwise, the element is straightened (10.3.2.3.c) and each element of the resulting multiple value is output {hh} or input {ii} using the next "picture" {cc, gg} from the current format.

cc) A "picture" is the yield of a picture. It is composed of a "pattern"of some specific 'TYPE' (according to the syntax of the TYPE-pattern of that picture) , followed by an "insertion" {ee}. Patterns, apart from 'choice', 'format' and 'general' patterns, are composed of "frames", possibly "suppressed", each of which has an insertion, a "replicator" {dd}, and a "marker" to indicate whether it is a "d", "z", "i" etc. frame. The frames of each pattern may be grouped into "sign moulds", "integral moulds", etc., according to the syntax of the corresponding pattern.

dd) A "replicator" is a routine, returning an integer, constructed from a replicator {10.3.4.1.2.c}, For example, the replicator 10 gives rise to a routine composed from INT: 10; moreover, n (lim - 1) is a "dynamic" replicator and gives rise to INT: (lim - 1) . Note that the scope of a replicator restricts the scope of any format containing it, and thus it may be necessary to take a local copy of a file before associating a format with it (see, e.g.. 11.D) . A replicator which returns a negative value is treated as if it had returned zero ("k" alignments apart) .

When a picture is "staticized", all of its replicators and other routines (including those contained in its insertions) are called collaterally. A staticized pattern may be said to "control" a string, and there is then a correspondence between the frames of that pattern, taken in order, and the characters of the string. Each frame controls n consecutive characters of the string, where n is 0 for an "r" frame and, otherwise, is the integer returned by the replicator of the frame (which is always 1 for a "+", "-", ".", "e", "i" or "b" frame) . Each controlled character must be one of a limited set appropriate to that frame.

ee) An "insertion", which is the yield of an insertion {10.3.4.1.2.d}, is a sequence of replicated "alignments" and strings: an insertion containing no alignments is termed a "literal". An insertion is "performed" by performing its alignments {ff} and on output (input) writing ("expecting" {ll}) each character of its replicated strings (a string is replicated by repeating it the number of times returned by its replicator) .

ff) An "alignment" is the character yielded by an alignment-code {10.3.4.1.2.d}. An alignment which has been replicated n times is performed as follows:

"k" causes set char number to be called, with n as its second parameter:
"x" causes space to be called n times:
"y" causes backspace to be called n times:
"l" causes newline to be called n times:
"p" causes newpage to be called n times;
"q" on output (input) causes the character blank to be written (expected) n times.

gg) A format may consist of a sequence of pictures, each of which is selected in turn by get next picture {10.3.5.b}. In addition, a set of pictures may be grouped together to form a replicated "collection" (which may contain further such collections) . When the last picture in a collection has been selected, its first picture is selected again, and so on until the whole collection has been repeated n times, where n is the integer returned by its replicator. A collection may be provided with two insertions, the first to be performed before the collection, the second afterwards.

A format may also invoke other formats by means of 'format' patterns {10.3.4.9.1}.

When a format has been exhausted, the event routine corresponding to on format end is called; if this returns false, the format is repeated; otherwise, if the event routine has failed to provide a new format, undefined is called.

hh) A value V is output, using a picture P, as follows:
If the pattern Q of P is a 'choice' or 'general' pattern,
then V is output using P (See 10.3.4.3.1.aa,dd , 10.3.4.10.1.aa);
otherwise, V is output as follows:

  • P is staticized;
    If the mode of V is "output compatible" with Q (see the separate section dealing with each type of pattern) ,
    then
      V is converted into a string controlled {dd} by Q (See the appropriate section);
    If the mode is not output compatible, or if the conversion is unsuccessful,
    then
      • the event routine corresponding to on value error is called;
      • if this returns false, V is output using put and undefined is called;
    otherwise, the string is "edited" (jj) using Q:
  • the insertion of P is performed.

ii) A value is input to a name N, using a picture P, as follows:
If the pattern Q of P is a 'choice' or 'general' pattern,
then a value is input to N using P (see 10.3.4.8.1.bb,ee , 10.3.4.10.1.bb);
otherwise,

  • P is staticized;
  • a string controlled by Q is "indited" {kk};
    If the mode of N is "input compatible" with Q (see the appropriate section) ,
    then
      • the string is converted to an appropriate value suitable for N using Q (see the appropriate section):
      • if the conversion is successful, the value is assigned to N;
    If the mode is not input-compatible, or if the conversion is unsuccessful,
    then
      • the event routine corresponding to on value error is called;
      • if this returns false, undefined is called;
  • the insertion of P is performed.

jj) A string is "edited", using a pattern P, as follows:
In each part of the string controlled by a sign mould,

    • if the first character of the string (which indicates the sign) is "+" and the sign mould contains a "-" frame, then that character is replaced by " "
    • the first character (i.e., the sign) is shifted to the right across all leading zeroes in this part of the string and these zeroes are replaced by spaces (for example, using the sign mould 4z+, the string "+0003" becomes "+ 3"
In each part of the string controlled by an integral mould,
    • zeroes controlled by "z" frames are replaced by spaces as follows:
      • between the start of the string and the first nonzero digit;
      • between each "d", "e" or "i" frame and the next nonzero digit;
      (for example, using the pattern zdzd2d the string "180168" becomes "18 168";)
For each frame F of P,
    • the insertion of F is performed.
    • if F is not suppressed, the characters controlled by F are written;
    (for example, the string "+0003.5", when edited using the pattern 4z+ s. "," d, causes the string " +3,5" to be written and the string "180168", using the pattern zd"-"zd"-19"2d, gives rise to "18- 1-1968") .

kk) A string is "indited", using a pattern P, as follows:
For each frame F of P,

    • the insertion of F is performed.
    For each element of the string controlled by F, a character is obtained as follows:
    If F is contained in a sign mould,
    then
      • if a sign has been found, a digit is expected, with "0" as suggestion;
      • otherwise, either a "+" or a "-" is expected, with "0" as suggestion, and, in addition, if the sign mould contains a frame, then a space preceding the first digit will be accepted as the sign (and replaced by "+");
    otherwise, if F is contained in an integral mould,
    then
      If F is suppressed,
      then "0" is supplied,
      otherwise:
        Case A: F is a "d" frame:
          • a digit is expected, with "0" as suggestion;
        Case B: if F is "z" frame:
          • a digit or space is expected, with "0" as suggestion, but a space is only acceptable as follows:
            • between the start of the string and the first nonzero digit;
            • between each "d", "e" or "i" frame and the next nonzero digit;

          • such spaces are replaced by zeroes.

    otherwise, if F is an "a" frame,
    then if F is not suppressed, a character is read and supplied; otherwise " " is supplied;
    otherwise, if F is not suppressed,
    then
      if F is a "." ("e", "i", "b") frame, a "." ("10" or "\" or "e", "I" or "i", flip or flop) is expected, with "." ("10", "I", flop) as suggestion;
    otherwise, if F is a suppressed "." ("e", "i") frame, the character "." ("10", "I") is supplied.

ll) A member of a set of characters S is "expected", with the character C as suggestion, as follows:
• a character is read;
If that character is one of the expected characters (i.e., a member of S) ,
then that character is supplied;
otherwise,

    the event routine corresponding to on char error is called, with C as suggestion; if this returns true and C, as possibly replaced, is one of the expected characters, then that character is supplied; otherwise, undefined is called.}

10.3.4.1.2. Semantics

{A format is brought into being by means of a format-text. A format is best regarded as a tree, with a collection at each node and a picture at each tip. In order to avoid violation of the scope restrictions, each node of this tree is, in this Report, packed into a value of mode 'PIECE'. A format is composed of a row of such pieces and the pieces contain pointers to each other in the form of indices selecting from that row. An implementer will doubtless store the tree in a more efficient manner. This is possible because the field-selector of a format is hidden from the user in order that he may not break it open.

Although a format-text may contain ENCLOSED-clauses (in replicators and format-patterns) or units (in general-patterns,) these are not elaborated at this stage but are, rather, turned into routines for subsequent calling as and when they are encountered during formatted transput. Indeed, the elaboration of a format-text does not result in any actions of any significance to the user.}

a) The yield of a format-text F, in an environ E, is a structured value whose only field is a multiple value W, whose mode is 'row of PIECE', composed of a descriptor ((1, n)) and n elements determined as follows:
• a counter i is set to 1;
F is "transformed" {b} in E into W, using i.

b) A format-text or a collection-list-pack C is "transformed" in an environ E into a multiple value W whose mode is 'row of PIECE', using a counter i, as follows:
• the element of W selected by (i) is a structured value, whose mode is 'PIECE' and whose fields, taken in order, are

    • {cp} undefined;
    • {count} undefined;
    • {bp} undefined;
    • {c} a multiple value V whose mode is "row of COLLECTION", having a descriptor ((1,m)) , where m is the number of constituent collections of C, and elements determined as follows:
    For j = 1, ... m, letting Cj be the j-th constituent collection of C,

    Case A: The direct descendents of Cj include a picture P.

      • the constituent pattern P if any and the insertion I of P are elaborated collaterally;
      • the j-th element of V is a structured value, whose mode is 'PICTURE' and whose fields, taken in order are
    Case B:
      The direct descendents of Cj, include a first insertion I1, a replicator REP, a collection-list-pack P and a second insertion I2:
      i is increased by 1;
      I1, REP and I2 are elaborated collaterally;
      • the j-th element of V is a structured value whose mode is 'COLLITEM' and whose fields, taken in order, are
        • {i1} the yield of I1 {d};
        • {rep} the yield of REP {c};
        • {p} i;
        • {i2} the yield of I2;
      P is transformed in E into W, using i.
c) The yield, in an environ E, of a NEST-UNSUPPRESSETY-replicator R {10.3.4.1.1.g, h} is a routine whose mode is 'procedure yielding integral', composed of a procedure-yielding-integral-NEST-routine-text whose unit is U, together with the environ necessary {7.2.2.c} for U in E, where U is determined as follows:

Case A: R contains a meek-integral-ENCLOSED-clause C:

Case B: R contains a fixed-point-numeral D, but no ENCLOSED-clause:

    U is a new unit akin to D;

Case C: R is invisible:

    U is a new unit akin to a fixed-point-numeral which has an intrinsic value {8.1.1.2} of 1.

d) The yield of an insertion I {10.3.4.1.1.d} is a multiple value W whose mode is 'INSERTION', determined as follows:
• let U1, ... , Un be the constituent UNSUPPRESSETY-replicators of I, and let Ai, i = 1, ... n, be the denoter-coercee or alignment-code {immediately} following Ui:
• let R1, ... , Rn and D1, ... , Dn the {collateral} yields of U1, ... , Un and A1, ... , An, where the yield of an alignment-code is the {character which is the} intrinsic value {8.1.4.2.b} of its LETTER-symbol;
• the descriptor of W is ((1, n));
• the element of W selected by (i) , i = 1, ..., n, is a structured value {of the mode specified by STRUCT (PROC INT rep, UNION (STRING, CHAR) sa) } whose fields, taken in order, are

    • {rep} Ri;
    • {sa} Di.
e) The yield of an integral-, real-, boolean-, complex-, string- or bits-pattern P {10.3.4.2.1.a , 10.3.4.3.1.a , 10.3.4.4.1.a, 10.3.4.5.1.a , 10.3.4.6.1.a, 10.3.4.7.1.a} is a structured value W whose mode is 'PATTERN', determined as follows:
• let V1, ... , Vn be the {collateral} yields of the constituent frames of P {f};
• the fields of W, taken in order, are
• {type} 1 (2, 3, 4, 5) if P is an integral- (real-, boolean-, complex-, string-) -pattern and 6 (8, 12, 20) if P is a bits-pattern whose constituent RADIX is a radix-two (-four, -eight, -sixteen);
• {frames} a multiple value, whose mode is 'row of FRAME', having a descriptor ((1, n)) and n elements, that selected by (i) being Vi.

f) The yield of a frame F {10.3.4.1.1.m} is a structured value W whose mode is 'FRAME', determined as follows:
• the insertion and the replicator, it any, of F are elaborated collaterally:
• the fields of W, taken in order, are

    • {i} the yield of its insertion;
    • {rep} the yield of its replicator {c}, if any, and, otherwise, the yield of an invisible replicator:
    • {supp} true if its first UNSUPPRESSETY-suppression contains a letter-s-symbol and, otherwise, false:
    • {marker} (the character which is the intrinsic value {8.1.4.2.b} of a symbol S determined as follows:
    Case A: F is a constituent unsuppressible-zero-frame of a sign-mould {such as 3z+} whose constituent sign-marker contains a plus-symbol:
      • S is a letter-u-symbol.
    Case B: F is a constituent unsuppressible-zero-frame of a sign-mould {such as 3z-} whose constituent sign-marker contains a minus-symbol:
      • S is a letter-v-symbol.
    Other cases:
      S is the constituent symbol of the marker of F.
{Thus the zero-marker z may be passed on as the character "u", "v" or "z" according to whether it forms part of a sign-mould (with descendent plus-symbol or minus-symbol) or of an integral-mould.}

10.3.4.2. Integral patterns

10.3.4.2.1. Syntax

a) NEST integral pattern {A341c ,A343c} : NEST sign mould {c} option, NEST integral mould {b}.
b) NEST integral mould {a,A343b,c ,A347a} : NEST digit frame {A341k} sequence.
c) NEST sign mould {a,A343a} : NEST unsuppressible zero frame {A341k} sequence option, NEST unsuppressible sign frame {A341j} .
d) zero marker {f,A341k} : letter z {94a} symbol.
e) sign marker {A341j} : plus {94c} symbol ; minus {94c} symbol.
f) digit marker {A341k} : letter d {94a} symbol ; zero marker {d}.

{Examples:  
a) "x=" 12z+d
b) d
c) "x=" 12z+ }
{For the semantics of integral-patterns see 10.3.4.1.2.e .}

{aa) The modes which are output (input) compatible with an 'integral' pattern are those specified by L INT (by REF L INT) .

bb) A value V is converted to a string S using an 'integral' pattern P as follows:
• if P contains a sign mould, the first character of S is the sign of V; otherwise, if V < 0, the conversion is unsuccessful;
• the remainder of S contains a decimal representation of V determined as follows:

    • the elements of S controlled by "d" and "z" frames are the appropriate digits (thus the pattern specifies the number of digits to be used);
    • if V cannot be represented by such a string, the conversion is unsuccessful;
(For example, the value 99 could be converted to a string using the pattern zzd, but 9999 and -99 could not.)

cc) A string S is converted to an integer suitable for a name N, using an 'integral' pattern, as follows:
• the integer I for which S contains a decimal representation {8.1.1.2} is considered;
• if I is greater than the largest value to which N can refer, the conversion is unsuccessful; otherwise, I is the required integer (e.g., if the mode of N is specified by REF SHORT INT, and the value of short max int is 65535, then no string containing a decimal representation of a value greater than 65535 may be converted) .}

10.3.4.3. Real patterns

10.3.4.3.1. Syntax

a) NEST real pattern {A341c, A345a} : NEST sign mould {A342c} option, NEST variable point mould {b} or alternatively NEST floating point mould {c}.
b) NEST variable point mould {a,c} : NEST integral mould {A342b} option ; NEST point frame {A341j} , NEST integral mould {A342b} option.
c) NEST floating point mould {a} : NEST variable point mould {b} or alternatively NEST integral mould {A342b} , NEST exponent frame {A341j} , NEST integral pattern {A342a} .
d) point marker {A341j} : point {94b} symbol.
e) exponent marker {A341j} : letter e {94a} symbol.

{Examples:  
a) +zd.11d • +.12de+2d
b) zd.11d • +.12d
c) .12de+2d } 
{For the semantics of real-patterns see 10.3.4.1.2.e .}

{aa) The modes which are output (input) compatible with a 'real' pattern are those specified by L REAL and L INT (by REF L REAL) .

bb) A value V is converted to a string S using a 'real' pattern P as follows:
• if P contains a sign mould, the first character of S is the sign of V; otherwise, if V < 0, the conversion is unsuccessful;

• the remainder of S contains a decimal representation of V determined as follows:

    • if necessary, V is widened to a real number;
    • the element of S controlled by the "." ("e") frame, if any, of P is "." ("10");

    If P contains an "e" frame,
    then
    • let W be the sequence of frames preceding, and IP be the 'integral' pattern following, that "e" frame;
    • an exponent E is calculated by standardizing V to the largest value convertible using W (see below);
    • the part of S controlled by IP is obtained by converting E using IP (see 10.3.4.2.bb)
otherwise,
    • let W be the whole of P;
• the elements of S controlled by the "d" and "z" frames of W are the appropriate digits to be used, and the number of digits to be placed after the decimal point, if any);
• if V cannot be represented by such a string, the conversion is unsuccessful.

cc) A string S is converted to a real number suitable for a name N, using a 'real' pattern P, as follows:
• the real number R for which S contains a decimal representation is considered;
• if R is greater than the largest value to which N can refer, the conversion is unsuccessful; otherwise, R is the required real number.}

10.3.4.4. Boolean patterns

10.3.4.4.1. Syntax

a) NEST boolean pattern {A341c} : NEST unsuppressible boolean frame {A341j} .
b) boolean marker {A341j ,A348b} : letter b {94a} symbol.

{Example:  
a) 14x b }
{For the semantics of boolean-patterns see 10.3.4.1.2.e .}

{aa) The mode which is output (input) compatible with a 'boolean' pattern is that specified by BOOL (REF BOOL)

bb) A value V is converted to a string using a 'boolean' pattern as follows:
• if V is true (false) , then the string is that yielded by flip (flop) .

cc) A string S is converted to a boolean value, using a 'boolean' pattern, as follows:
• if S is the same as the string yielded by flip (flop) , then the required value is true (false) .}

10.3.4.5. Complex patterns

10.3.4.5.1. Syntax

a) NEST complex pattern {A341c} : NEST real pattern {A343a} , NEST complex frame {A341j} , NEST real pattern {A343a} .
b) complex marker {A341j} : letter i {94a} symbol.

{Example:  
a) +.12de+2d 3q"+j×"3" "si+.10de+2d }

{For the Semantics of complex-patterns see 10.3.4.1.2.e .}

{aa) The modes which are output (input) compatible with a 'complex' pattern are those specified by L COMPL , L REAL and L INT (by REF L COMPL) .

bb) A value V is converted to a string S using a 'complex' pattern P as follows:
• if necessary, V is widened to a complex number;
• the element of S controlled by the "i" frame of P is "↑";
• the part of S controlled by the first (second) 'real' pattern of P is that obtained by converting the first (second) field of V to a string using the first (second) 'real' pattern of P {10.3.4.3.1.bb}
• if either conversion is unsuccessful, the conversion of V is unsuccessful.
cc) A string is converted to a complex value C suitable for a name N, using a 'complex' pattern P, as follows:
• the part of the string controlled by the first (second) 'real' pattern of P is converted to a suitable real number {10.3.4.3.1.cc}, which then forms the first (second) field of C.
• if either conversion is unsuccessful, the conversion to C is unsuccessful.}

10.3.4.6. String patterns

10.3.4.6.1. Syntax

a) NEST string pattern {A341c} : NEST character frame {A341k} sequence.
b) character marker {A341k} : letter a {94a} symbol.

{Example:  
a) p "table of"x 10a }
{For the semantics of string-patterns see 10.3.4.1.2.e .} {

aa) The modes which are output (input) compatible with a 'string' pattern are those specified by CHAR and [] CHAR (by REF CHAR, REF [] CHAR and REF STRING) .

bb) A value V is converted to a string using a 'string' pattern P as follows:
• if necessary, V is rowed to a string:
• if the length of the string V is equal to the length of the string controlled by P, then V is supplied: otherwise, the conversion is unsuccessful,

cc) A string S is converted to a character or a string suitable for a name N, using a 'string' pattern, as follows:
Case A: The mode of N is specified by REF CHAR:

    • if S does not consist of one character, the conversion is unsuccessful: otherwise, that character is supplied:
Case B: The mode of N is specified by REF [] CHAR:
    • if the length of S is not equal to the number of characters referred to by N, the conversion is unsuccessful: otherwise, S is supplied,
Case C: The mode of N is specified by REF STRING:
    S is supplied.}

10.3.4.7. Bits patterns

10.3.4.7.1. Syntax

a) NEST bits pattern {A341c} : NEST RADIX frame {b}, NEST integral mould {A342b} .
b) NEST RADIX frame {a} : NEST insertion {A341d} , RADIX {82d,e,f,g} , unsuppressible suppression {A341l} , radix marker {c}.
c) radix marker {b} : letter r {94a} symbol.

{Examples:
a) 2r6d26sd     
b) 2r
}

{For the semantics of bits-patterns, see 10.3.4.1.2.e .}

{aa) The modes which are output (input) compatible with a 'bits'-pattern are those specified by L BITS (REF L BITS) .

bb) A value V is converted to a string using a 'bits' pattern P as follows:
• the integer I corresponding to V is determined, using the operator ABS {10.2.3.8.i};
If the "r" frame of P was yielded by a radix-two- (-four-, -eight-, -sixteen-) -frame,
then

    I is converted to a string, controlled by the integral mould of P, containing a binary (quaternary, octal, hexadecimal) representation of I (cf. 10.3.4.2.1.bb);
    • if I cannot be represented by such a string, the conversion is unsuccessful.

cc) A string S is converted to a bits value suitable for a name N, using a 'bits' pattern P, as follows:
• if the "r" frame of P was yielded by a radix-two- (-four-, -eight-, -sixteen-) -frame, then the integer I for which S contains a binary (quaternary, octal, hexadecimal) representation is determined;
• the bits value B corresponding to I is determined, using the operator BIN (10.2.3.8.j) :
• if the width of B is greater than that of the value to which N refers, the conversion is unsuccessful.}

10.3.4.8. Choice patterns

10.3.4.8.1. Syntax

a) NEST integral choice pattern {A341c} : NEST insertion {A341d} , letter c {94a} symbol, NEST praglit {c} list brief pack, pragment {92a} sequence option.
b) NEST boolean choice pattern {A341c} : NEST insertion {A341d} , boolean marker {A344b} , brief begin {94f} token, NEST praglit {c}, and also {94f} token, NEST praglit {c}, brief end {94f} token, pragment {92a} sequence option.
c) NEST praglit {a,b} : pragment {92a} sequence option, NEST literal {A341i} .

{Examples:  
a) 120kc ("mon", "tues", "wednes", "thurs", "fri", "satur", "sun")       
b) b ("","error")      
c) "mon" }

{aa) A value V is output using a picture P whose pattern Q was yielded by an integral-choice-pattern C, as follows:
• the insertion of Q is staticized {10.3.4.1.1.dd} and performed {10.3.4.1.1.ee};
If the mode of V is specified by INT, if V > 0 and if the number of constituent literals in the praglit-list-pack of C is at least V,
then

    • the literal yielded by the V-th literal is staticized and performed;
otherwise,
    • the event routine corresponding to on value error is called;
    • if this returns false, V is output using put and undefined is called;
• the insertion of P is staticized and performed.

bb) A value is input to a name N using a picture P whose pattern Q was yielded by an integral-choice-pattern C as follows:
• the insertion of Q is staticized and performed,
• each of the literals yielded by the constituent literals of the praglit-list-pack of C is staticized and "searched for" {cc} in turn:
If the mode of N is specified by REF INT and the i-th literal is the first one present.
then i is assigned to N:
otherwise,

    • the event routine corresponding to on value error is called;
    • if this returns false, undefined is called;
• the insertion of P is staticized and performed.

cc) A literal is "searched for" by reading characters and matching them against successive characters of the literal. If the end of the current line or the logical end of the file is reached, or if a character fails to match, the search is unsuccessful and the current position is returned to where it started from.

dd) A value V is output using a picture P whose pattern Q was yielded by a boolean-choice-pattern C as follows:
• the insertion of Q is staticized and performed:
If the mode of V is specified by BOOL,
then
• if V is true (false) , the literal yielded by the first (second) constituent literal of C is staticized and performed:
otherwise,

    • the event routine corresponding to on value error is called;
    • if this returns false, V is output using put and undefined is called;
• the insertion of P is staticized and performed.

ee) A value is input to a name N using a picture P whose pattern Q was yielded by a boolean-choice-pattern C as follows:
• the insertion of Q is staticized and performed;
• each of the literals yielded by the constituent literals of C is staticized and searched for in turn:
If the mode of N is specified by REF BOOL, and the first second) insertion is present,
then true (false) is assigned to N:
otherwise,

    • the event routine corresponding to on value error is called;
    • if this returns false, undefined is called;
• the insertion of P is staticized and performed.}

10.3.4.8.2. Semantics

The yield of a choice-pattern P is a structured value W whose mode is 'CPATTERN', determined as follows:
• let n be the number of constituent NEST-literals of the praglit-list-pack of P;
• let Si, i = 1, ..., n, be a NEST-insertion akin {1.1.3.2.k} to the i-th of those constituent NEST-literals:
• the insertion I of P and all of S1, S2, ... , Sn are elaborated collaterally:
• the fields of W, taken in order, are

    • {i} the yield of I:
    • {type} 1 (2) if P is a boolean- (integral-) -choice-pattern;
    • {c} a multiple value whose mode is 'row of INSERTION', having a descriptor ((1, n)) and n elements, that selected by (i) , i = 1, ... n, being the yield of Si.

10.3.4.9. Format patterns

10.3.4.9.1. Syntax

a) NEST format pattern {A341c} : NEST insertion {A341d} , letter f {94a} symbol, meek FORMAT NEST ENCLOSED clause {31a ,34a} , pragment {92a} sequence option.

{Example:  
a) f (uir | (INT): $5d$, (REAL): $d.3d$) } 

{A format-pattern may be used to provide formats dynamically for use in transput. When a 'format' pattern is encountered during a call of get next picture, it is staticized and its insertion is performed. The first picture of the format returned by the routine of the pattern is supplied as the next picture, and subsequent pictures are taken from that format until it has been exhausted.}

10.3.4.9.2. Semantics

The yield, in an environ E, of a NEST-format-pattern P is a structured value whose mode is 'FPATTERN' and whose fields, taken in order, are
• {i} the yield of its insertion;
• {pf} a routine whose mode is 'procedure yielding FORMAT', composed of a procedure-yielding-FORMAT-NEST-routine-text whose unit U is a new unit akin {1.1.3.2.k} to the meek-FORMAT-ENCLOSED-clause of P, together with the environ necessary for U in E.

10.3.4.10. General patterns

10.3.4.10.1. Syntax

a) NEST general pattern {A341c} : NEST insertion {A341d} , letter g {94a} symbol, NEST width specification {b} option.
b) NEST width specification {a} : brief begin {94f} token ; meek integral NEST unit {32d} , NEST after specification {c} option, brief end {94f} token, pragment {92a} sequence option.
c) NEST after specification {b} : and also {94f} token, meek integral NEST unit {32d} , NEST exponent specification {d} option.
d) NEST exponent specification {c} : and also {94f} token, meek integral NEST unit {32d} .

{Examples:  
a) g • g(-18, 12, -3)       
b) -18, 12, -3     
c) , 12, -3     
d) , -3 } 

{aa) A value V is output using a picture P whose pattern Q was yielded by a general-pattern G as follows:
P is staticized;
• the insertion of Q is performed;
If Q is not parametrized (i.e., Q contains no width-specification) .
then V is output using put;
otherwise, if the mode of V is specified by L INT or L REAL ,
then

    • if Q contains one (two, three) parameter (s) , V is converted to a string using whole (fixed, float);
      • the string is written using put;
    otherwise,
      • the event routine corresponding to on value error is called;
      • if this returns false, V is output using put, and undefined is called;
    • the insertion of P is performed.

bb) A value is input to a name N using a picture P whose pattern is a 'general' pattern as follows:
P is staticized;
• (any parameters are ignored and) the value is input to N using get.}

10.3.4.10.2. Semantics

The yield, in an environ E, of a NEST-general-pattern P is a structured value whose mode is 'GPATTERN' and whose fields, taken in order, are
• {i} the yield of the insertion of P:
• {spec} a multiple value W whose mode is 'row of procedure yielding integral', having a descriptor ((1, n)) , where n is the number of constituent meek-integral-units of the width-specification-option of P, and n elements determined as follows: For i = 1, ... n,

    • the i-th element of W is a routine, whose mode is 'procedure yielding integral', composed of a procedure-yielding-integral-NEST-routine-text whose unit U is a new unit akin {1.1.3.2.k} to the i-th of those meek-integral-units, together with the environ necessary for U in E.

10.3.5. Formatted transput

a) MODE FORMAT = STRUCT (FLEX [1: 0] PIECE F);
   MODE ? PIECE = STRUCT (INT cp ¢ pointer to current collection ¢,
      count ¢ number of times piece is to be repeated¢,
      bp ¢ back pointer ¢,
      FLEX [1 : 0] COLLECTION c);
   MODE ? COLLECTION = UNION (PICTURE, COLLITEM) :
   MODE ? COLLITEM = STRUCT (INSERTION i1,
      PROC INT rep; ¢ replicator ¢,
      INT p ¢ pointer to another piece ¢, INSERTION i2);
   MODE ? INSERTION = FLEX [1: 0] STRUCT (PROC INT rep ¢ replicator ¢,
      UNION (STRING, CHAR) sa);
   MODE ? PICTURE =
      STRUCT (UNION (PATTERN, CPATTERN, FPATTERN, GPATTERN, VOID) p, INSERTION i);
   MODE ? PATTERN = STRUCT (INT type ¢ of pattern ¢,   
      FLEX [1: 0] FRAME frames) ,
   MODE ? FRAME = STRUCT (INSERTION i,   
      PROC INT rep ¢ replicator ¢,
      BOOL supp ¢ true if suppressed ¢,
      CHAR marker);
   MODE ? CPATTERN = STRUCT (INSERTION i,
      INT type ¢ boolean or integral ¢,
      FLEX [1 : 0] INSERTION c);
   MODE ? FPATTERN = STRUCT (INSERTION i, PROC FORMAT pf);
   MODE ? GPATTERN = STRUCT (INSERTION i, FLEX [1 : 0] PROC INT spec);

b) PROC ? get next picture = (REF FILE f, BOOL read, REF PICTURE picture) VOID:
      BEGIN
      BOOL picture found := FALSE, format ended := FALSE;
      WHILE NOT picture found
      DO IF forp OF f = 0 THEN
            IF format ended
            THEN undefined
            ELIF NOT (format mended OF f) (f) 
            THEN REF INT (forp OF f) := 1;
               cp OF (F OF format OF f) [1] := 1;
               count OF (F OF format OF f) [1] := 1
            ELSE format ended := TRUE
            FI
         ELSE REF INT forp = forp OF f;
            REF FLEX [] PIECE aleph = F OF format OF f;
            CASE (c OF aleph [forp]) [cp OF aleph [forp]] IN
               (COLLITEM cl) :
                  ([1 : UPB (i1 OF cl) ] SINSERT si;
                   bp OF alph[p OF cl] := forp; forp := SKIP;
                   (staticize insertion ( i1 OF cl, si) ,
                      count OF aleph [p OF cl] := rep OF cl);
                   (aleph :≠: F OF format OF f | undefined);
                   (read | get insertion (f, si) | put insertion (f, si));
                   cp OF aleph[p OF cl] := 0;
                   forp := p OF cl) ,
               (PICTURE pict): (picture found := TRUE; picture := pict) 
            ESAC;
            WHILE
               (forp ≠ 0 | cp OF aleph[forp] = UPB c OF aleph[forp]) | FALSE) 
            DO IF (count OF aleph[forp] -:= 1) ≤ 0
            THEN
               IF (forp := bp OF aleph [forp]) ≠ 0
               THEN
                  INSERTION extra =
                     CASE (c OF aleph [forp]) [cp OF aleph [forp]] IN
                     (COLLITEM cl) :
                        (bp OF aleph [p OF cl] := 0; i2 OF cl) ,
                     (PICTURE pict) :
                        CASE p OF pict IN
                           (FPATTERN fpatt):  
                              (INT k := forp;
                               WHILE bp OF aleph [k] ≠ forp DO k +:= 1 OD;
                               aleph := aleph [ : k - 1];
                               i OF pict) 
                        ESAC
                     ESAC;
                  INT m = UPB i OF picture, n = UPB extra;
                  [1 : m + n] STRUCT (PROC INT rep, UNION (STRING, CHAR) sa) c;
                  c[1 : m] := i OF picture; c[m + 1 : m + n] := extra;
                  i OF picture := c
                       FI
               ELSE cp OF aleph [forp] := 0
               FI OD;
               (forp ≠ 0 | cp OF aleph [forp] +:= 1) 
         FI OD
      END;

c) MODE ? SINSERT = STRUCT (INT rep, UNION (STRING , CHAR) sa);

d) PROC ? staticize insertion = (INSERTION ins, REF [] SINSERT sins) VOID:
      ¢ calls collaterally all the replicators in 'frames' ¢
      IF UPB ins = 1  
      THEN
         rep OF sins[1] := rep OF ins[1];
         sa OF sins[1] := sa OF ins[1]
      ELIF UPB ins > 1
      THEN (staticize insertion (ins[1], sins[1]) ,
              staticize insertion (ins[2 : ], sins[2 : ]) 
      FI;

e) MODE ? SFRAME = STRUCT (FLEX [1 : 0 ] SINSERT si, INT rep, BOOL supp, CHAR marker);

f) PROC ? staticize frames =
      ([] FRAME frames, REF [] SFRAME sframes) VOID:  
         ¢ calls collaterally all the replicators in 'frames' ¢
      IF UPB frames = 1
      THEN
         [1 : UPB (i OF frames [1]) ] SINSERT si;
         (staticize insertion (i OF frames[1], si) ,
            rep OF sframes [1] := rep OF frames [1]);
         si OF sframes [1] := si;
         supp OF sframes [1] := supp OF frames [1];
         marker OF sframes [1] := marker OF frames[1]
      ELIF UPB frames > 1
      THEN (staticize frames (frames[1], sframes[1]) .
              staticize frames (frames[2 : ], sframes[2 : ])) 
      FI;

g) PROC ? put insertion = (REF FILE f, [] SINSERT si) VOID:
      BEGIN set write mood (f);
         FOR k TO UPB si
         DO
            CASE sa OF si[k] IN
               (CHAR a): alignment (f, rep OF si[k], a, FALSE) ,
               (STRING s) :
                  TO rep OF si[k]
                  DO
                     FOR i TO UPB s
                     DO checkpos (f); putchar (f, s[i]) OD
                  OD
            ESAC          
         OD
      END;

h) PROC ? get insertion (REF FILE f, [] SINSERT si) VOID:
      BEGIN set read mood (f);
         FOR k TO UPB si
         DO
            CASE sa OF si[k] IN
               (CHAR a): alignment (f, rep OF si [k], a, TRUE) ,
               (STRING s) :
                  (CHAR c;
                   TO rep OF si[k]
                   DO
                      FOR i TO UPB s
                      DO checkpos (f); get char (f, c);
                         (c ≠ s[i]
                         | (NOT (char error mended OF f) (f, c := s[i]) 
                         | undefined);
                         set read mood (f)) 
                      OD
                   OD) 
            ESAC  
         OD
      END;

i) PROC ? alignment = (REF FILE f, INT r, CHAR a, BOOL read) VOID:
      IF a = "x" THEN TO r DO space (f) OD
      ELIF a = "y" THEN TO r DO backspace (f) OD
      ELIF a = "l" THEN TO r DO newline (f) OD
      ELIF a = "p" THEN TO r DO newpage (f) OD
      ELIF a = "k" THEN set char number (f, r) 
      ELIF a = "q" 
      THEN TO r
         DO
            IF read
            THEN CHAR c; check pos (f); get char (f, c);
               (c ≠ blank
               | (NOT (char error mended OF f) (f, c := blank) 
               | undefined); set read mood (f)) 
            ELSE check pos (f); put char (f, blank) 
            FI
         OD 
      FI;

j) PROC ? do fpattern = (REF FILE f, FPATTERN fpattern, BOOL read) VOID:
      BEGIN FORMAT pf;
         [1 : UPB (i OF fpattern) ] SINSERT si;
         (staticize insertion (i OF fpattern, si) , 
            pf := pf OF fpattern);
         (read | get insertion (f, si) | put insertion (f, si));
         REF INT forp = forp OF f;
         REF FLEX [] PIECE aleph = F OF format OF f;
         INT m = UPB aleph, n = UPB (F OF pf);
         [1 : m + n] PIECE c; c[1 : m] := aleph;
         c[m + 1 : m + n] := F OF pf;
         aleph := c; bp OF aleph[m + 1] := forp;
         forp := m + 1; cp OF aleph[forp] := 0;
         count OF aleph[forp] := 1;
         FOR i FROM m + 1 TO m + n
         DO
            FOR j TO UPB c OF aleph[i]
            DO
               CASE (c OF aleph[i]) [j] IN
                  (c OF aleph[i]) [j] := 
                     COLLITEM (i1 OF cl, rep OF cl, p OF cl + m, i2 OF cl) 
               ESAC
            OD
         OD
     END;

k) PROC ? associate format = (REF FILE f, FORMAT format) VOID:
      BEGIN 
         format OF f :=
            C a newly created name which is made to refer to the yield
            of an actual-format-declarer and whose scope is equal to
            the scope of the value yielded by 'format' C
               := format;
         forp OF f := HEAP INT := 1;
         cp OF (F OF format OF f) [1] := 1;
         count OF (F OF format OF f) [1] := 1;
         bp OF OF (F OF format OF f) [1] := 1
      END;

10.3.5.1. Formatted output

a) PROC putf = (REF FILE f, [] UNION (OUTTYPE, FORMAT) x) VOID:
      IF opened OF f THEN       
      FOR k TO UPB x
      DO CASE set write mood (f); set char mood (f); x[k] IN
         (FORMAT format): associate format (f, format) ,
         (OUTTYPE ot) :
         BEGIN INT j := 0;
            PICTURE picture, [] SIMPLOUT y = STRAIGHTOUT ot;
            WHILE (j +:= 1) ≤ UPB y
            DO BOOL incomp := FALSE;
               get next picture (f, FALSE, picture);
               set write mood (f);
               [1 : UPB (i OF picture) ] SINSERT sinsert;
               CASE p OF picture IN
               (PATTERN pattern) :
               BEGIN INT rep, sfp := 1; 
                  [1 : UPB (frames OF pattern) ] SFRAME sframes;
                  (staticize frames (frames OF pattern, sframes) ,
                     staticize insertion (i OF picture, sinsert));
                  STRING s;
                  
                  OP ? = (STRING s) BOOL:
                     ¢ true if the next marker is one of the elements of 
                        's' and false otherwise ¢
                     IF sfp > UPB sframes
                     THEN FALSE
                     ELSE SFRAME sf = sframes[sfp];
                        rep := rep OF sf:
                        IF char in string (marker OF sf, LOC INT, s) 
                        THEN sfp +:= 1; TRUE
                        ELSE FALSE
                        FI
                     FI;

                  OP ? = (CHAR c) BOOL: ? STRING (c);

                  PROC int pattern (REF BOOL sign mould) INT:
                     (INT l := 0;
                      WHILE ? "zuv" DO (rep ≥ 0 | l +:= rep) OD;
                      sign mould := ? "+-";
                      WHILE ? "zd" DO (rep ≥ 0 | l +:= rep) OD; l);
                             
                  «PROC edit L int (L INT i) VOID:
                            (BOOL sign mould; INT l := int pattern (sign mould);
                             STRING t = subwhole (ABS i, l);
                             IF char in string (errorchar, LOC INT, t) OR l = 0
                                   OR NOT sign mould AND i < L 0
                             THEN incomp := TRUE
                             ELSE t PLUSTO s;
                                (l - UPB t) × "0" PLUSTO s;
                                (sign mould | (i < L 0 | "-" | "+") PLUSTO s) 
                             FI) »;
   
                  «PROC edit L real (L  REAL r) VOID:
                            (INT b := 0, a := 0, e := 0, exp := 0, L  REAL y := ABS r,
                             BOOL sign1, STRING point := "";
                             b := int pattern (sign1);
                             (? "." | a := int pattern (LOC BOOL); point := ".");
                             IF ? "e"
                             THEN L standardize (y, b, a, exp);
                                edit int (exp);
                                "10" PLUSTO s
                             FI;
                             STRING t = subfixed (y, b + a + (a ≠ 0 | 1 | 0) , a);
                             IF char in string (errorchar, LOC INT, t) OR a + b = 0
                                   OR NOT sign1 AND r < L 0 AND exp < 0
                             THEN incomp := TRUE
                             ELSE t[ : b] + point + t[b + 2 : ] PLUSTO s;
                                (b + a + (a ≠ 0 | 1 | 0) - UPB t) × "0" PLUSTO s;
                                (sign1 | (r < L 0 | "-" | "+") PLUSTO s) 
                             FI) »;
                         
                  «PROC edit L compl = (L COMPL z) VOID:
                            (WHILE NOT ? "i" DO sfp +:= 1 OD; edit L real (IM z);
                             "I" PLUSTO s; sfp := 1; edit L real (RE z)) »;
                           
                  «PROC edit L bits (L BITS lb, INT radix) VOID:
                            (L INT n := ABS lb; ? "r"; INT l := intpattern (LOC BOOL);
                             WHILE dig char (S (n MOD K radix)) PLUSTO s;
                                 n %:= K radix; n ≠ L 0
                             DO SKIP OD;   
                             IF UPB s ≤ l
                             THEN (l - UPB s) × "0" PLUSTO s
                             ELSE incomp := TRUE
                             FI) »;
                        
                  PROC charcount = INT: (INT l := 0; 
                     WHILE ? "a" DO (rep ≥ 0 | l +:= rep) OD; l);
                             
                  CASE type OF pattern IN
               ¢ integral ¢
                     (y[j] |
                     « (L INT i): edit L int (i) »
                     | incomp := TRUE) ,
               ¢ real ¢
                     (y[j] |
                     « (L  REAL r): edit L real (r) »
                     « (L INT i): edit L real (i) »
                     | incomp := TRUE) ,
               ¢ boolean ¢
                     (y[j] |
                     (BOOL b): s := (b | flip | flop) 
                     | incomp := TRUE) ,
               ¢ complex ¢
                     (y[j] |
                     « ( L COMPLEX z): edit L complex (z) »
                     « (L  REAL r): edit L complex (r) »
                     « (L INT i): edit L complex (i) »
                     | incomp := TRUE) ,
               ¢ string ¢
                     (y[j] |
                     (CHAR c): (charcount = 1 | s := c | incomp := TRUE) ,
                     ([] CHAR t) :
                        (charcount = UPB t - LWB t + 1
                        | s := t[@1]
                        | incomp := TRUE) 
                             | incomp := TRUE)  
                  OUT
               ¢ bits ¢
                     (y[j] |
                     « (L BITS lb): edit L bits (lb, type OF pattern - 4) »
                     | incomp := TRUE) 
                  ESAC;
                  IF NOT incomp
                  THEN edit string (f, s, sframes) 
                  FI
               END,
               (CPATTERN choice) :
               BEGIN
                  [1 : UPB (i OF choice)] SINSERT si;
                  staticize insertion (i OF choice, si) :
                  put insertion (f, si);
                  INT l =
                     CASE type OF choice IN
                  ¢ boolean ¢
                        (y [j] |
                        (BOOL b): (b | 1 | 2) 
                        | incomp := TRUE; SKIP) ,
                  ¢ integral ¢
                        (y [j] |
                        (INT i): i   
                        | incomp := TRUE; SKIP) 
                     ESAC;
                     IF NOT incomp
                     THEN
                        IF l > UPB (c OF choice) OR l ≤ 0
                        THEN incomp := TRUE
                        ELSE
                           [1 : UPB ((c OF choice) [l])) SINSERT ci:
                           staticize insertion ((c OF choice) [l], ci);
                           put insertion (f, ci) 
                        FI
                     FI;
                     staticize insertion (i OF picture, sinsert) 
               END,
               (FPATTERN fpattern:
               BEGIN
                  do fpattern (f, fpattern, FALSE);
                  FOR TO UPB sinsert DO sinsert[i] := (0, "") OD;
               END,
               (GPATTERN gpattern) :
               BEGIN
                  [1 : UPB (i OF gpattern) ] SINSERT si;
                  [] PROC INT spec = spec OF gpattern; INT n = UPB spec;
                  [1 : n] INT s;  
                  (staticize insertion (i OF gpattern, si) ,
                     staticize insertion (i OF picture, sinsert) ,
                     s := (n | spec[1], (spec[1], spec[2]) ,
                          (spec[1], spec[2], spec[3]) | ()));
                  put insertion (f, si);
                  IF n = 0 THEN put (f, y[j]) 
                  ELSE
                     NUMBER yj =
                        (y[j] | « (L INT i): i», « (L  REAL r): r»
                        | incomp := TRUE; SKIP);
                     IF NOT incomp
                     THEN CASE n IN
                        put (f, whole (yj, s[1])) ,
                        put (f, fixed (yj, s[1], s[2])) ,
                        put (f, float (yj, s[1], s[2], s[3])) 
                        ESAC
                     FI
                  FI
               END,
               (VOID) :
                  (j -:= 1; staticize insertion (i OF picture, sinsert)) 
               ESAC;
               IF incomp
               THEN set write mood (f);
                  (NOT (value error mended OF f) (f) | put (f, y [j]) :
                     undefined) 
               FI;
               put insertion (f, sinsert) 
            OD
         END
      ESAC OD
      ELSE undefined
      FI;

b) PROC ? edit string (REF FILE f, STRING s, [] SFRAME sf) VOID:
      BEGIN BOOL supp, zs := TRUE, signput := FALSE, again, INT j := 0, sign;
         PROC copy = (CHAR c) VOID:
            (NOT supp | check pos (f); put char (f, c));
         FOR k TO UPB sf
         DO SFRAME sfk = sf[k]; supp := supp OF sfk:
            put insertion (f, si OF sfk);
            TO rep OF sfk
            DO again := TRUE;
               WHILE again
               DO j +:= 1; again := FALSE;
                  CHAR sj = s[j], marker = marker OF sfk;
                  IF marker = "d"
                  THEN copy (sj); zs := TRUE
                  ELIF marker = "z" THEN
                       (sj = "0" | copy ((zs | " " | sj)) 
                       |: sj = "+" | again := TRUE
                       | zs := FALSE; copy (sj)) 
                  ELIF marker = "u" OR marker = "v" THEN
                       (sj = "+" | sign := 1; again := TRUE
                       |: sj = "-" | sign := 2; again := TRUE
                       |: sj = "0" | copy ((zs | " " | sj)) 
                       | (NOT signput |
                         copy ((sign | (marker = "u" | "+" | " ") , "-"));
                         signput := TRUE);
                         copy (sj); zs := FALSE) 
                  ELIF marker = "+" then
                       (sj = "+" OR sj = "-" | copy (sj) 
                       | (NOT signput | copy ((sign | "+", "-")));
                          j -:= 1) 
                  ELIF marker = "-" THEN
                       (sj = "+" | copy (" ") 
                       |: sj = "-" | copy (sj) 
                       | (NOT signput | copy ((sign | " ", "-")));
                          j -:= 1) 
                  ELIF marker = "." THEN
                       copy (".") 
                  ELIF marker = "e" OR marker = "i"  
                       OR marker = "a" OR marker = "b"
                  THEN copy (sj); zs := TRUE; signput := FALSE
                  ELIF marker = "r"
                  THEN j -:= 1
                  FI
               OD
            OD
         OD
      END;

10.3.5.2. Formatted input

a) PROC getf = (REF FILE f, [] UNION (INTYPE, FORMAT) x) VOID:
      IF opened OF f THEN
         FOR k TO UPB x
         DO CASE set read mood (f); set char mood (f); x[k] IN
            (FORMAT format): associate format (f, format) ,
            (INTYPE it) :
            BEGIN INT j := 0;
               PICTURE picture, [] SIMPLIN y = STRAIGHTIN it;
               WHILE (j +:=- 1) ≤ UPB y
               DO BOOL incomp := FALSE;
                  get next picture (f, TRUE, picture); set read mood (f);
                  [1 : UPB (i OF picture) ] SINSERT sinsert;
                  CASE p OF picture IN
                  (PATTERN pattern) :
                  BEGIN
                     [1 : UPB (frames OF pattern) ] SFRAME sframes;
                     (staticize frames (frames OF pattern, sframes) ,
                        staticize insertion (i OF picture, sinsert));
                     STRING s;
                     INT radix =
                        (type OF pattern ≥ 6 | type OF pattern - 4 | 10);
                     indit string (f, s, sframes, radix);
                     CASE type OF pattern IN
                  ¢ integral ¢
                        (y[j] |
                        « (REF L INT ii) :
                        incomp := NOT string to L int (s, 10, ii) »
                        | incomp := TRUE) ,
                  ¢ real ¢
                        (y[j] |
                        « (REF L  REAL rr) :
                           incomp := NOT string to L real (s, rr) »
                        | incomp := TRUE) ,
                  ¢ boolean ¢
                        (y[j] |
                        (REF BOOL bb): bb := s = flip
                        | incomp := TRUE) ,
                  ¢ complex ¢
                        (y[j] |
                        « (REF L COMPL zz) :
                           (INT i, BOOL bi, b2; char in string ("I", i, s);
                            b1 := string to L real (s [ : i - 1], re OF zz);
                            b2 := string to L real (s [i + 1 : ], im OF zz);
                            incomp := NOT (b1 AND b2)) »
                        | incomp := TRUE) ,
                  ¢ string ¢
                        (y[j] |
                        (REF CHAR cc) :
                           (UPB s = 1 | cc := s[1] | incomp := TRUE) ,
                        (REF [] CHAR ss) :
                           (UPB ss - LWB ss + 1 = UPB s | ss[@1] := s
                           | incomp := TRUE) ,
                        (REF STRING ss): ss := s
                        | incomp := TRUE) 
                     OUT
                  ¢ bits ¢
                        (y[j] |
                        « (REF L BITS lb) :
                           IF L INT i; string to L int (s, radix, i) 
                           THEN lb := BIN i
                           ELSE incomp := TRUE
                           FI»
                        | incomp := TRUE) 
                     ESAC
                  END, 
                  (CPATTERN choice) :
                  BEGIN
                     [1 : UPB (i OF choice) SINSERT si;
                     staticize insertion (i OF choice, si);
                     get insertion (f, si);
                     INT c = c OF cpos OF f, CHAR kk;
                     INT k := 0, BOOL found := FALSE;
                     WHILE k < UPB (c OF choice) AND NOT found
                     DO k +:= 1;
                        [1 : UPB ((c OF choice) [k]) ] SINSERT si;
                        BOOL bool := TRUE;
                        staticize insertion ((c OF choice, [k], si);
                        STRING s;
                        FOR i TO UPB si
                        DO s PLUSAB
                           (sa OF si[i] | (STRING ss): ss) × rep OF si[i]
                        OD;   
                        FOR jj TO UPB s
                        WHILE bool := bool AND NOT line ended (f) 
                           AND NOT logical file ended (f) 
                        DO get char (f, kk); bool := kk = s[jj] OD;
                        (NOT (found := bool) | set char number (f, c)) 
                     OD; 
                     IF NOT found THEN incomp := TRUE
                     ELSE
                        CASE type OF choice IN
                     ¢ boolean ¢
                           (y [j] |
                           (REF BOOL b): b := k = 1
                           | incomp := TRUE) ,
                     ¢ integral ¢
                           (y [j] |
                           (REF INT i): i := k
                           | incomp := TRUE) 
                        ESAC
                     FI;
                     staticize insertion (i OF picture, sinsert) 
                  END,
                  (FPATTERN fpattern): 
                  BEGIN do fpattern (f, fpattern, TRUE);
                     FOR i TO UPB sinsert DO sinsert [i] := (0, "") OD;
                     j -:= 1
                  END,
                  (GPATTERN gpattern) :
                     ([1 : UPB (i OF gpattern) ] SINSERT si;
                     (staticize insertion (i OF gpattern, si) ,
                        staticize insertion (i OF picture, sinsert));
                     get insertion (f, si);
                     get (f, y[j])) ,
                  (VOID) :
                     (j -:= 1; staticize insertion (i OF picture, sinsert)) 
                  ESAC;
                  IF incomp
                  THEN set read mood (f);
                     (NOT (value error mended OF f) (f) | undefined) 
                  FI;
                  get insertion (f, sinsert) 
               OD
            END
         ESAC OD
      ELSE undefined
      FI;

b) PROC ? indit string = (REF FILE f, REF STRING s, [] SFRAME sf, INT radix) VOID:
      BEGIN
         BOOL supp, zs := TRUE, sign found := FALSE, space found := FALSE,
            nosign := FALSE, INT sp := 1, rep;
         PRIO ! = 8;
                         
         OP ! = (STRING s, CHAR c) CHAR :
               ¢ expects a character contained in 's'; if the character
               read is not in 's', the event routine corresponding to 'on
               char error' is called with the suggestion 'c' ¢
            IF CHAR k; checkpos (f); get char (f, k);
               char in string (k, LOC INT, s) 
            THEN k
            ELSE CHAR sugg := c;
               IF (char error mended OF f) (f, sugg) THEN
                   (char in string (sugg, LOC INT, s) | sugg | undefined; c) 
               ELSE undefined; c   
               FI;
               set read mood (f);
            [[above five lines should read
               CHAR cc = IF (char error mended OF f) (f, sugg) THEN
                  (char in string (sugg, LOC INT, s) | sugg | undefined; c) 
                 ELSE undefined; c
                 FI;
               set read mood (f); cc]]
            FI;

         OP ! = (CHAR s, c) CHAR: STRING (s) ! c;

         [] CHAR good digits = "0123456789abcdef"[ : radix];
         s := "+";
         FOR k TO UPB sf
         DO SFRAME sfk = sf[k]; supp := supp OF fsk;
            get insertion (f, si OF sfk);  
            TO rep OF sfk
            DO CHAR marker = marker OF sfk;
               IF marker = "d" THEN
                  s PLUSAB (supp | "0" | good digits ! "0"); zs := TRUE
                 ELIF marker = "z" THEN
                    s PLUSAB (supp | "0"   
                       | CHAR c = ((zs | " " | "") + good digits) ! "0";
                          (c ≠ " " | zs := FALSE); c) 
                 ELIF marker = "u" OR marker = "+" THEN
                      IF sign found
                      THEN zs := FALSE; a PLUSAB ("0123456789" ! "0") 
                      ELSE CHAR c = ("+-" + (marker = "u" | " " | "")) ! "+";
                         (c = "+" OR c = "-" | sign found := TRUE; s[sp] := c) 
                      FI
                 ELIF marker = "v" OR marker = "-" THEN
                      IF sign found
                      THEN zs := FALSE; z PLUSAB ("0123456789" ! "0") 
                      ELIF CHAR c; space found
                      THEN c := "+- 0123456789" ! "+";
                         (c = "+" OR c = "-" | sign found := TRUE; s[sp] := c
                         |: c ≠ " " | zs := FALSE; sign found := TRUE; s PLUSAB c) 
                      ELSE c := "+- " ! "+";
                         (c = "+" OR c = "-" | sign found := TRUE; s[sp] := c
                         | space found := TRUE) 
                      FI
                 ELIF marker ="." THEN
                      s PLUSAB (supp | "." | "."! ".") 
                 ELIF marker = "e" THEN
                      s PLUSAB (supp | "10" | "10\e" ! "10"; "10"); sign found := FALSE;
                      zs := TRUE; s PLUSAB "+"; sp := UPB s
                 ELIF marker = "i" THEN  
                      s PLUSAB (supp | "I" | "iI"! "I"; "I");
                      sign found := FALSE; zs := TRUE; s PLUSAB "+"; sp := UPB s
                 ELIF marker = "b" THEN  
                      s PLUSAB (flip + flop) ! flop; no sign := TRUE
                 ELIF marker = "a" THEN
                      s PLUSAB (supp | " " | CHAR c; check pos (f); get char (f, c);
                      c);
                      no sign := TRUE
                 ELIF marker = "r"
                 THEN SKIP
                 FI
            OD
         OD;
         IF no sign THEN s := s[2 : ] FI
      END;

10.3.6. Binary transput

{In binary transput, the values obtained by straightening the elements of a data list (cf. 10.3.3) are transput, via the specified file, one after the other. The manner in which such a value is stored in the book is defined only to the extent that a value of mode M (being some mode from which that specified by SIMPLOUT is united) output at a given position may subsequently be re-input from that same position to a name of mode 'reference to M'. Note that, during input to the name referring to a multiple value, the number of elements read will be the existing number of elements referred to by that name.

The current position is advanced after each value by a suitable amount and, at the end of each line or page, the appropriate event routine is called, and next, if this returns false, the next good character position of the book is found (cf. 10.3.3) .

For binary output, put bin (10.3.6.1.a) and write bin (10.5.1.h) may be used and, for binary input, get bin (10.3.6.2.a) and read bin (10.5.1.i).}

a) PROC ? to bin = (REF FILE f, SIMPLOUT x) [] CHAR:
      C a value of mode 'row of character' whose lower bound is one
         and whose upper bound depends on the value of 'book OF f'
         and on the mode and the value of 'x';  furthermore,
         x = from bin (f, x, to bin (f, x)) C;  

b) PROC ? from bin = (REF FILE f, SIMPLOUT y. [] CHAR c) SIMPLOUT: 
      C a value, if one exists, of the mode of the value yielded by 'y',
         such that c = to bin (f, from bin (f, y, c)) C;

10.3.6.1. Binary output

a) PROC put bin = (REF FILE f, [] OUTTYPE ot) VOID:
      IF opened OF f THEN 
         set bin mood (f); 
         set write mood (f); 
         FOR k TO UPB ot DO 
             [] SIMPLOUT y = STRAIGHTOUT ot [k]; 
             FOR j TO UPB y DO 
                 [] CHAR bin = to bin (f, y[j]); 
                 FOR i TO UPB bin DO 
                     next pos (f); 
                     set bin mood (f); 
                     REF POS cpos = cpos OF f, lpos = lpos OF book OF f; 
                     CASE text OF f IN 
                        (FLEXTEXT t2): t2 [p OF cpos ] [l OF cpos] [c OF cpos] := bin [i] 
                     ESAC; 
                     c OF cpos+:= 1; 
                     IF cpos BEYOND lpos THEN 
                        lpos := cpos 
                     ELIF NOT set possible (f) AND POS (p OF lpos, l OF lpos, 1) BEYOND cpos THEN 
                          lpos := cpos; (compressible (f) | C the size of the line and page containing the
                                                               logical end of the book and of all
                                                               subsequent lines and pages may be
                                                               increased C) 
                     FI
                 OD
             OD
         OD 
      ELSE undefined
      FI;

10.3.6.2. Binary input

a) PROC get bin = (REF FILE f, [] INTYPE it) VOID:
      IF opened OF f THEN
         set bin mood (f); set read mood (f);  
         FOR k TO UPB it
         DO [] SIMPLIN y = STRAIGHTIN it [k];
            FOR j TO UPB y
            DO
               SIMPLOUT yj = CASE y[j] IN
                  « (REF L INT i): i»,
                  « (REF L  REAL r): r»,
                  « (REF L COMPL z): z»,
                  (REF BOOL b): b,
                  « (REF L BITS lb): lb»,
                  (REF CHAR c): c, 
                  (REF [] CHAR s): s,
                  (REF STRING ss): ss ESAC;
               [1 : UPB (to bin (f, yj)) ] CHAR bin;
               FOR i TO UPB bin
               DO next pos (f); set bin mood (f);
                  REF POS cpos = cpos OF f;
                  bin[i] :=
                     CASE text OF f IN
                        (FLEXTEXT t2) :
                           t2[p OF cpos][l OF cpos][c OF cpos]
                     ESAC;
                  c OF cpos +:= 1
               OD;
               CASE y[j] IN
                  « (REF L INT ii): (from bin (f, ii, bin) | (L INT i): ii := i) »,
                  « (REF L  REAL rr) :
                     (from bin (f, rr, bin) | (L  REAL r): rr := r) »,
                  « (REF L COMPL zz) :
                     (from bin (f, zz, bin) | (L COMPL z): zz := z) »,
                  (REF BOOL bb): (from bin (f, bb, bin) | (BOOL b): bb := b) ,
                  « (REF L BITS lb) :
                     (from bin (f, lb, bin) | (L BITS b): lb := b) »,  
                  (REF CHAR cc): ( from bin (f, cc, bin) | (CHAR c): cc := c) ,
                  (REF []CHAR ss) :
                     (from bin (f, ss, bin) | ([] CHAR s): ss := s) ,
                  (REF STRING ssss) :
                     (from bin (f, ssss, bin) | ([] CHAR s): ssss := s) 
               ESAC
            OD
         OD
      ELSE undefined
      FI;

{But Eeyore wasn't listening. He was taking
the balloon out, and putting it back again,
as happy as could be. ...
Winnie-the-Pooh, A.A.Milne.}

{
eeyore }

10.4. The system prelude and task list

10.4.1. The system prelude

The representation of the system-prelude is obtained from the following form, to which may be added further forms not defined in this Report. {The syntax of program-texts ensures that a declaration contained in the system-prelude may not contradict any declaration contained in the standard-prelude. It is intended that the further forms should contain declarations that are needed for the correct operation of any system-tasks that may be added (by the implementer, as provided in 10.1.2.d) .}

a) SEMA ? gremlins = (SEMA s; F OF s := PRIM INT :=  0; s);

10.4.2. The system task list

The representation of the {first} constituent system-task or the system-task-list is obtained from the following form. The other system-tasks, if any, are not defined by this Report {but may be defined by the implementer in order to account for the particular features of his operating environment, especially in so far as they interact with the running of particular-programs (see, e.g., 10.3.1.1.dd)} .

a) DO DOWN gremlins; undefined; UP bfileprotect OD

{The intention is that this call of undefined, which is released by an UP gremlins whenever a book is closed, may reorganize the chain of backfiles and the chain of locked backfiles, such as by removing the book if it is not to be available for further opening, or by inserting it into the chain of backfiles several times over if it is to be permitted for several particular-programs to read it simultaneously. Note that, when an UP gremlins is given, bfileprotect is always down and remains so until such reorganization has taken place.}

{From ghoulies and ghosties and long-leggety beasties
and things that go bump in the night,
Good Lord, deliver us!
Ancient Cornish litany}

10.5. The particular preludes and postludes

10.5.1. The particular preludes

The representation of the particular-prelude of each user-task is obtained from the following forms, to which may be added such other forms as may be needed for the proper functioning of the facilities defined in the constituent library-prelude of the program-text {, e.g., declarations and calls of open for additional standard files}. However, for each QUALITY-new-new-PROPS1-LAYER2-defining-indicator-with-TAX contained in such an additional form, the predicate 'where QUALITY TAX independent PROPS1' (7.1.1.a, c) must hold {i.e., no declaration contained in the standard-prelude may be contradicted} .

a) L INT L last random := ROUND (L maxint / L  2);  

b) PROC L random = L  REAL: L next random (L last random);

c) FILE stand in, stand out, stand back;
   open (stand in,  "", stand in channel);
   open (stand out, "", stand out channel);
   open (stand back,  "", stand back channel);

d) PROC print = ([] UNION (OUTTYPE, PROC (REF FILE) VOID) x) VOID:
      put (stand out, x) , 
   PROC write = ([] UNION (OUTTYPE, PROC (REF FILE) VOID) x) VOID:
      put (stand out, x); 

e) PROC read = ([] UNION (INTYPE, PROC (REF FILE) VOID) x) VOID:
      get (stand in, x); 

f) PROC printf = ([] UNION (OUTTYPE, FORMAT) x) VOID:
      putf (stand out, x) , 
   PROC writef = ([] UNION (OUTTYPE, FORMAT) x) VOID:
      putf (stand out, x);

g) PROC readf = ([] UNION (INTYPE, FORMAT) x) VOID:
      getf (stand in, x);  

h) PROC write bin = ([] OUTTYPE x) VOID:
      put bin (stand back, x);  

i) PROC read bin = ([] INTYPE x) VOID:
     get bin (stand back, x);

10.5.2. The particular postludes

The representation of the particular-postlude of each user-task is obtained from the following form, to which may be added such other forms as may be needed for the proper functioning of the facilities defined in the constituent library-prelude of the program-text {, e.g., calls of lock for additional standard files}.

a) stop: lock (stand in); lock (stand out); lock (stand back)   

«Table of contents»

11. Examples

11.1. Complex square root

PROC compsqrt = (COMPL z) COMPL :
   ¢ the square root whose real part is nonnegative of the complex number 'z' ¢
   BEGIN REAL x = RE z, y = IM z;
       REAL rp = sqrt ((ABS x + sqrt (x ↑ 2 + y ↑ 2)) / 2);
       REAL ip = (rp = 0 | 0 | y / (2 × rp));
       IF x ≥ 0 THEN rp I ip ELSE ABS ip I (y ≥ 0 | rp | -rp) FI
   END

Calls {5.4.3} using compsqrt:

compsqrt (w) 
compsqrt (-3.14) 
compsqrt (-1) 

11.2. Innerproduct 1

PROC innerproduct1 = INT n, PROC INT) REAL x, y) REAL :
      ¢ the innerproduct of two vectors, each with 'n' components, x (i) ,
      y (i) , i = 1, ..., n, where 'x' and 'y' are arbitrary mappings
      from integer to real numbers ¢
   BEGIN LONG REAL s := LONG 0;
       FOR i TO n DO s +:= LENG x (i) × LENG y (i) OD;
       SHORTEN s
   END

Real-calls using innerproduct 1:

innerproduct1 (m, (INT j) REAL: x1[j], (INT j) REAL: y1[j]) 
innerproduct1 (n, nsin, ncos) 

11.3. Innerproduct 2

PROC innerproduct 2 = (REF [] REAL a, b) REAL:
   IF UPB a - LWB a = UPB b - LWB b
   THEN ¢ the innerproduct of two vectors 'a' and 'b' with equal numbers
      of elements ¢ 
      LONG REAL s := LONG 0;
      REF [] REAL a1 = a[@1], b1 = b[@1];
      ¢ note that the bounds of 'a[@1]' are [1 : UPB a - LWB a + 1] ¢
      FOR i TO UPB a1 DO s +:= LENG a1[i] × LENG b1[i] OD;
      SHORTEN s
   FI

Real-calls using innerproduct 2:

innerproduct2 (x1, y1) 
innerproduct2 (y2[2, ], y2[, 3]) 

11.4. Largest element

PROC absmax = (REF [, ] REAL a, ¢ result ¢ REF REAL y, 
   ¢ subscripts ¢ REF INT i, k) VOID:
      ¢ the absolute value of the element of greatest absolute value of
      the matrix 'a' is assigned to 'y', and the subscripts of this
      element to 'i' and 'k'¢
    BEGIN y := -1;
       FOR p FROM 1 LWB a TO 1 UPB a
       DO
          FOR q FROM 2 LWB a TO 2 UPB a
          DO
             IF ABS a[p, q] > y THEN y := ABS a[i := p, k := q] FI
          OD
      OD
   END

Calls using absmax:

absmax (x2, x, i, j) 
absmax (x2, x, LOC INT, LOC INT) 

11.5. Euler summation

PROC euler = (PROC (INT) REAL f, REAL eps, INT tim) REAL:
      ¢ the sum for 'i' from 1 to infinity of 'f (i) ', computed by means of
      a suitably refined Euler transformation. The summation is
      terminated when the absolute values of the terms of the
      transformed series are found to be less than 'eps' 'tim' times in
      succession. This transformation is particularly efficient in the
      case of a slowly convergent or divergent alternating series ¢
   BEGIN INT n := 1, t; REAL mn, ds := eps; [1 : 16] REAL m;
      REAL sum := (m[1] := f (1)) / 2;
      FOR i FROM 2 WHILE (t := ABS ds < eps | t + 1 | 1)) ≤ tim
      DO mn := f (i);
         FOR k TO n DO mn := ((ds := mn)) + m[k]) / 2; m[k] := ds OD;
         sum +:= (ds := (ABS mn < ABS m[n] AND n < 16 | n +:= 1; m[n] := mn;
            mn / 2 | mn)) 
      OD;
      sum
   END

A call using euler:

euler ((INT i) REAL: (ODD i | -1 / i | 1 / i) , 1.e-5, 2) 

11.6. The norm of a vector

PROC norm = (REF [] REAL a) REAL :
      ¢ the euclidean norm of the vector 'a' ¢
   (LONG REAL s := LONG 0;
    FOR k FROM LWB a TO UPB a DO s +:= LENG a[k] ↑ 2 OD;
    SHORTEN long sqrt (s)) 
For a use of norm in a call, see 11.7 .

11.7. Determinant of a matrix

PROC det = (REF [, ] REAL x, REF [] INT p) REAL :
   IF REF [, ] REAL a = x[@1, @1];
         1 UPB a = 2 UPB a AND 1 UPB a = UPB p - LWB p + 1
   THEN INT n = 1 UPB a;
         ¢ the determinant of the square matrix 'a' of order 'n' by the
         method of Crout with row interchanges: 'a' is replaced by its
         triangular decomposition, l × u, with all u[k, k] = 1.
         The vector 'p' gives as output the pivotal row indices; the k-th
         pivot is chosen in the k-th column of T such that
         ABS l[i, k] / row norm is maximal ¢
      [1 : n] REAL v; REAL d := 1, s, pivot;
      FOR i TO n DO v[i] := norm (a[i, ]) OD;
      FOR k TO n
      DO INT k1 = k - 1; REF INT pk = p[@1][k]; REAL r := -1;
         REF [, ] REAL al = a[, 1 : k1], au = a[1 : k1,];
         REF [] REAL ak = a[k, ], ka = a[, k], alk = al[k, ], kau = au[, k];
         FOR i FROM k TO n
         DO REF REAL aik = ka[i];
            IF (s := ABS (aik -:= innerproduct2 (al[i, ], kau)) / v[i]) > r
            THEN r := s; pk := i
            FI
         OD;
         v[pk] := v[k]; pivot := ka[pk]; REF [] REAL apk = a[pk, ];
         FOR j TO n
         DO REF REAL akj = ak[j], apkj = apk[j];
            r := akj;
            akj := IF j ≤ k THEN apkj
               ELSE (apkj - innerproduct2 (alk, au[, j])) / pivot FI;
            IF pk ≠ k THEN apkj := -r FI
         OD;
         d ×:= pivot
      OD;
      d
   FI

A call using det:

det (y2,i1)

11.8. Greatest common divisor

PROC gcd = (INT a, b) INT:
      ¢ the greatest common divisor of two integers ¢
   (b = 0 | ABS a | gcd (b, a MOD b))

A call using gcd:

gcd (n, 124)

11.9. Continued fraction

OP / = ([] REAL a, [] REAL b) REAL:
      ¢ the value of a / b is that of the continued fraction
      a1 / (b1 + a2 / (b2 + ... an / bn) ...) ¢
   IF LWB a = 1 AND LWB b = 1 AND UPB a = UPB b
   THEN (UPB a = 0 | 0 | a[1] / (b[1] + a[2 : ] / b[2 : ]))
   FI

A formula using /:

x1 / y1

{The use of recursion may often be elegant rather than efficient as in the recursive procedure 11.8 and the recursive operation 11.9 . See, however, 11.10 and 11.13 for examples in which recursion is of the essence.}

11.10. Formula manipulation

BEGIN
   MODE FORM = UNION (REF CONST, REF VAR, REF TRIPLE, REF CALL);
   MODE CONST = STRUCT (REAL value);
   MODE VAR = STRUCT (STRING name, REAL value);
   MODE TRIPLE = STRUCT (FORM left operand, INT operator, FORM right operand);
   MODE FUNCTION = STRUCT (REF VAR bound var, FORM body);
   MODE CALL = STRUCT (REF FUNCTION function name, FORM parameter);
   INT plus = 1, minus = 2, times = 3, by = 4, to = 5;
   HEAP CONST zero, one; value OF zero := 0; value OF one := 1;
   OP = = (FORM a, REF CONST b) BOOL: (a | (REF CONST ec): ec :=: b | FALSE);
   OP + = (FORM a, b) FORM:
      a = zero | b |: b = zero | a | HEAP TRIPLE := (a, plus, b));
   OP - = (FORM a, b) FORM: (b = zero | a | HEAP TRIPLE := (a, minus, b));
   OP × = (FORM a, b) FORM: (a = zero OR b = zero | zero |: a = one | b |: b = one | a |
         HEAP TRIPLE := (a, times, b));
   OP / = (FORM a, b) FORM: (a = zero AND NOT (b = zero) | zero |: b = one | a |
         HEAP TRIPLE := (a, by, b));
   OP ↑ = (FORM a, REF CONST b) FORM:
      (a = one OR (b :=: zero) | one |: b :=: one | a | HEAP TRIPLE := (a, to, b));
   PROC derivative of = (FORM e, ¢ with respect to ¢ REF VAR x) FORM:
      CASE e IN
         (REF CONST): zero,
         (REF VAR ev): (ev :=: x | one | zero) ,
         (REF TRIPLE et) :
            CASE FORM u = left operand OF et, v = right operand OF et;
                 FORM udash = derivative of (u, ¢ with respect to ¢ x) ,
                 vdash = derivative of (v, ¢ with respect to ¢ x);
                 operator OF et
            IN
                 udash + vdash,
                 udash - vdash,
                 u × vdash + udash × v,
                 (udash - et × vdash) / v,
                 (v | (REF CONST ec): v × u ↑ (HEAP CONST c;
                    value OF c := value OF ec - 1; c) × udash)
            ESAC,
         (REF CALL ef) :
            BEGIN REF FUNCTION f = function name OF ef;
               FORM g = parameter OF ef; REF VAR y = bound var OF f;
               HEAP FUNCTION fdash := (y, derivative of (body OF f, y));
               HEAP CALL := (fdash, g)) × derivative of (g, x)
            END
      ESAC;
   PROC value of = (FORM e) REAL:
      CASE e IN
         (REF CONST ec): value OF ec,
         (REF VAR ev): value OF ev,
         (REF TRIPLE et) :
            CASE REAL u = value of (left operand OF et) ,
                 v = value of (right operand OF et);
                 operator OF et
            IN u + v, u - v, u × v, u / v, exp (v × ln (u))
            ESAC,
         (REF CALL ef) :
            BEGIN REF FUNCTION f = function name OF ef;
               value OF bound var OF f := value of (parameter OF ef);
               value of (body OF f)
            END
      ESAC;
   HEAP FORM f, g;
   HEAP VAR a := ("a", SKIP) , b := ("b", SKIP) , x := ("x", SKIP);
¢ start here ¢
   read ((value OF a, value OF b, value OF x));
   f := a + x / (b + x);
   g := (f + one) / (f - one);
   print ((value OF a, value OF b, value OF x,
      value of (derivative of (g, ¢ with respect to ¢ x))))
END ¢ example of formula manipulation ¢

11.11. Information retrieval

BEGIN
   MODE RA = REF AUTH, RB = REF BOOK;
   MODE AUTH = STRUCT (STRING name, RA next, RB book) ,
   BOOK = STRUCT (STRING title, RB next);
   RA auth, first auth := NIL, last auth;
   RB book; STRING name, title; INT i; FILE input, output;
   open (input, "", remote in); open (output, "", remote out);
   putf (output, ($p
      "to enter a new author, type ""author"", a space,"x
      "and his name."l
      "to enter a new book, type ""book"", a space,"x
      "the name of the author, a new line, and the title."l
      "for a listing of the books by an author, type ""list"","x
      "a space, and his name."l
      "to find the author of a book, type ""find"", a new line,"x
      "and the title."l
      "to end, type ""end"""al$, "."));

   PROC update = VOID:
      IF RA (first auth) :=: NIL
      THEN auth := first auth := last auth := HEAP AUTH := (name, NIL, NIL)
      ELSE auth := first auth;
           WHILE RA (auth) :≠: NIL
           DO
              (name = name OF auth | GO TO known | auth := next OF auth)
           OD;
           lastauth := next OF lastauth := auth :=
              HEAP AUTH := (name, NIL, NIL);
    known: SKIP
      FI;

   DO
   try again:
      getf (input, ($c ("author", "book", "list", "find", "end", "") ,x30al,
         80al$, i));

      CASE i IN

         ¢ author¢
         getf (input, name); update) ,

         ¢ book ¢
         BEGIN getf (input, (name, title)); update;
            IF RB (book OF auth) :=: NIL
            THEN book OF auth := HEAP BOOK := (title, NIL)
            ELSE book := book OF auth;
               WHILE RB (next OF book) :≠: NIL
               DO
                  (title = title OF book
                  | GO TO try again | book := next OF book)
               OD;
               (title ≠ title OF book
               | next OF book := HEAP BOOK := (title, NIL))
            FI
         END,

         ¢ list ¢
         BEGIN getf (input, name); update;
            putf (output, ($p"author: "30all$, name));
            IF RB (book := book OF auth) :=: NIL
            THEN put (output, ("no publications", newline))
            ELSE on page end (output,
               (REF FILE f) BOOL:
                  (putf (f, ($p"author: "30a41k"continued"ll$, name));
                   TRUE));
               WHILE RB (book) :≠: NIL
               DO putf (output, ($l80a$, title OF book)); book := next OF book
               OD;
               on page end (output, (REF FILE f) BOOL: FALSE)
            FI
         END,

         ¢ find ¢
         BEGIN getf (input, (LOC STRING, title)); auth := first auth;
            WHILE RA (auth) :≠: NIL
            DO book := book OF auth;
               WHILE RB (book) :≠: NIL
               DO
                  IF title = title OF book
                  THEN putf (output, ($l"author: "30a$, name OF auth));
                     GO TO try again
                  ELSE book := next OF book
                  FI
               OD;
               auth := next OF auth
            OD;
            put (output, (newline, "unknown", newline))
         END,

         ¢ end ¢
         (put (output, (new page, "signed off", close)); close (input);
          GOTO stop) ,

         ¢ error ¢
         (put (output, (newline, "mistake, try again")); newline (input))
      ESAC
   OD
END

11.12. Cooperating sequential processes

BEGIN INT nmb magazine slots, nmb producers, nmb consumers;
   read ((nmb magazine slots, nmb producers, nmb consumers));
   [1 : nmb producers] FILE in file; [1 : nmb consumers] FILE out file;
   FOR i TO nmb producers DO open (in file[i], "", inchannel[i]) OD;
      ¢ 'inchannel' and 'outchannel' are defined in a surrounding range ¢
      FOR i TO nmb consumers
      DO open (out file[i], "", outchannel[i]) OD;
      MODE PAGE = [1 : 60, 1 : 132] CHAR ;
      [1 : nmb magazine slots] REF PAGE magazine;
      INT ¢ pointers of a cyclic magazine ¢ index:= 1, exdex := 1;
      SEMA full slots = LEVEL 0, free slots = LEVEL nmb magazine slots,
      in buffer busy = LEVEL 1, out buffer busy = LEVEL 1;
      PROC par call = (PROC (INT) VOID p, INT n) VOID:
         ¢ call 'n' incarnations of 'p' in parallel ¢
         (n > 0 | PAR (p (n) , par call (p, n - 1)));
      PROC producer = (INT i) VOID:
         DO HEAP PAGE page;
            get (in file[i], page);
            DOWN free slots; DOWN in buffer busy;
            magazine[index] := page;
            index MODAB nmb magazine slots PLUSAB 1;
            UP full slots; UP in buffer busy
         OD;
      PROC consumer = (INT i) VOID:
         DO PAGE page;
            DOWN full slots; DOWN out buffer busy;
            page := magazine[exdex];
            exdex MODAB nmb magazine slots PLUSAB 1;
            UP free slots; UP out buffer busy;
            put (out file[i], page)
        OD;
      PAR (par call (producer, nmb producers) ,
         par call (consumer, nmb consumers))
 END

11.13. Towers of Hanoi

FOR k TO 8
DO FILE f := stand out;
   PROC p = (INT me, de, ma) VOID:
      IF ma > 0 THEN
           p (me, 6 - me - de, ma - 1);
           putf (f, (me, de, ma));
           ¢ move from peg 'me' to peg 'de' piece 'ma' ¢
           p (6-me-de, de, ma -1)
      FI ;
   putf (f, ($l"k = "dl,n ((2 ↑ k + 15) ÷ 16) (2(2(4(3(d)x)x)x)l)$, k));
   p (1, 2, k)
OD

«Table of contents»

12. Glossaries

12.1. Technical terms

Given below are the locations of the defining occurrences of a number of words which, in this Report, have a specific technical meaning. A word appearing in different grammatical forms is given once, usually as the infinitive. Terms which are used only within pragmatic remarks are enclosed within braces.

abstraction (a protonotion of a protonotion) 1.1.4.2.b
acceptable to (a value acceptable to a mode) 2.1.3.6.d
access (inside a locale) 2.1.2.c
action 2.1.4.1.a
active (action) 2.1.4.3.a
after (in the textual order) 1.1.3.2.i
akin (a production tree to a production tree) 1.1.3.2.k
{alignment} 10.3.4.1.1.ff
alternative 1.1.3.2.c
apostrophe 1.1.3.1.a
arithmetic value 2.1.3.1.a
ascribe (a value or scene to an indicator) 4.8.2.a
assign (a value to a name) 5.2.1.2.b
asterisk 1.1.3.1.a
{balancing} 3.4.1.b
before (in the textual order) 1.1.3.2.i
blind alley 1.1.3.2.d
{book} 10.3.1.1.b
bound 2.1.3.4.b
bound pair 2.1.3.4.b
built (the name built from a name) 6.6.2.c
built (the multiple value built from a value) 6.6.2.b
calling (of a routine) 5.4.3.2.b
{channel} 10.3.1.2.b
character 2.1.3.1.g
chosen (scene of a chooser-clause) 3.4.2.b
{close (a file)} 10.3.1.4.ff
collateral action 2.1.4.2.a
collateral elaboration 2.1.4.2.f
{collection} 10.3.4.1.1.gg
colon 1.1.3.1.a
comma 1.1.3.1.a
complete (an action) 2.1.4.3.c, d
{compressible} 10.3.1.3.ff
consistent substitute 1.1.3.4.e
constituent 1.1.4.2.d
construct 1.1.3.2.e
construct in a representation language 9.3.b
contain (by a hypernotion) 1.1.4.1.b
contain (by a production tree) 1.1.3.2.g
contain (by a protonotion) 1.1.4.1.b
{control (a string by a pattern)} 10.3.4.1.1.dd
{conversion key} 10.3.1.2.b
{create (a file on a channel)} 10.3.1.4.cc
{cross-reference (in the syntax)} 1.1.3.4.f
{data list} 10.3.3.b
defining range (of an indicator) 7.2.2.a
deflex (a mode to a mode) 2.1.3.6.b
{deproceduring} 6
{dereferencing} 6
descendent 1.1.3.2.g
descendent action 2.1.4.2.b
descriptor 2.1.3.4.b
designate (a hypernotion designating a protonotion) 1.1.4.1.a
designate (a paranotion designating a construct) 1.1.4.2.a
develop (a scene from a declarer) 4.6.2.c
direct action 2.1.4.2.a
direct descendent 1.1.3.2.f
direct parent 2.1.4.2.c
divided by (of arithmetic values) 2.1.3.1.e
{dynamic (replicator)} 10.3.4.1.1.dd
{edit (a string)} 10.3.4.1.1.jj
elaborate collaterally 2.1.4.2.f
elaboration 2.1.4.1.a
element (of a multiple value) 2.1.3.4.a
elidible hypernotion 1.1.4.2.c
endow with subnames 2.1.3.3.e, 2.1.3.4.g
envelop (a protonotion enveloping a hypernotion) 1.1.4.1.c
environ 2.1.1.1.c
{environment enquiry} 10.2
equivalence (of a character and an integer) 2.1.2.d, 2.1.3.1.g
equivalence (of modes) 2.1.1.2.a
equivalence (of protonotions) 2.1.1.2.a
establish (an environ around an environ) 3.2.2.b
{establish (a file on a channel)} 10.3.1.4.cc
{event routine} 10.3.1.3.b
{expect} 10.3.4.1.1.ll
{external object} 2.1.1.b
field 2.1.3.3.a
{file} 10.3.1.3.b
{firm (position)} 6.1.1.b
{firmly related} 7.1.1.b
fixed name (referring to a multiple value) 2.1.3.4.f
flat descriptor 2.1.3.4.c
flexible name (referring to a multiple value) 2.1.3.4.f
follow (in the textual order) 1.1.3.2.j
{format} 10.3.4.b
{frame} 10.3.5.1.bb
generate (a 'TAG' generating a name) 2.1.3.4.l
generate (a trim generating a name) 2.1.3.4.j
ghost element 2.1.3.4.c
halt (an action) 2.1.4.3.f
hardware language 9.3.a
{heap} 5.2.3.b
hold (of a predicate) 1.3.2.b
hold (of a relationship) 2.1.2.a
hyper-rule 1.1.3.4.b
hyperalternative 1.1.3.4.c
hypernotion 1.1.3.1.e
hyphen 1.1.3.1.a
identify (an indicator identifying an indicator) 7.2.2.b
implementation (of Algol 68) 2.2.2.c
implementation of the reference language 9.3.c
in (a construct in an environ) 2.1.5.b
in place of 3.2.2.a, 5.4.4.2.b
inactive (action) 2.1.4.3.a
incompatible actions 2.1.4.2.e
{independence (of properties)} 7.1.1.b
index (to select an element) 2.1.3.4.a
{indit (a string)} 10.3.4.1.1.kk
initiate (an action) 2.1.4.3.b, c
{input compatible} 10.3.4.1.1.ii
inseparable action 2.1.4.2.a
{insertion} 10.3.4.1.1.ee
integer 2.1.3.1.a
integral equivalent (of a character) 2.1.3.1.g
{internal object} 2.1.1.b
interrupt (an action) 2.1.4.3.h
intrinsic value 8.1.1.2, 8.1.2.2.a, b,8.1.4.2.b,8.2.2.b,c
invisible 1.1.3.2.h
is (of hypernotions) 2.1.5.e
large syntactic mark 1.1.3.1.a
largest integral equivalent (of a character) 2.1.3.1.g
lengthening (of arithmetic values) 2.1.2.d, 2.1.3.1.e
{link (a book with a file)} 10.3.1.4.bb
{literal} 10.3.4.1.1.ee
local environ 5.2.3.2.b
locale 2.1.1.1.b
{lock (a file)} 10.3.1.4.gg
{logical end} 10.3.1.1.aa
{logical file} 10.3.1.5.dd
lower bound 2.1.3.4.b
make to access (a value inside a locale) 2.1.2.c
make to refer to (of a name) 2.1.3.2.a
{marker} 10.3.4.1.1.cc
meaning 1.1.4, 2.1.4.1.a
meaningful program 1.1.4.3.c
{meek (position)} 6.1.1.b
member 1.1.3.2.d
metanotion 1.1.3.1.d
metaproduction rule 1.1.3.3.b
minus (of arithmetic values) 2.1.3.1.e
mode 2.1.1.2.b, 2.1.5.f
{multiple selection} 5.3.1.b
multiple value 2.1.3.4.a
name 2.1.3.2.a
necessary for (an environ for a scene) 7.2.2.c
nest 3.0.2.b
newer (of scopes) 2.1.2.f
newly created (name) 2.1.3.2.a
nil 2.1.3.2.a
nonlocal 3.2.2.b
notion 1.1.3.1.c
number of extra lengths 2.1.3.1.d
number of extra shorths 10.2.1.j, l, 2.1.3.1.d
number of extra widths 10.2.1.j, l
numerical analysis, in the sense of 2.1.3.1.e
object 2.1.1.b
of (construct of a construct) 2.1.5.a
of (construct of a scene) 2.1.1.1.d
of (environ of a scene) 2.1.1.1.d
of (nest of a construct) 3.0.2.b
older (of scopes) 2.1.2.f
{on routine} 10.3.1.3.b
{open (a file)} 10.3.1.4.dd
original 1.1.3.2.f
other syntactic mark 1.1.3.1.a
{output compatible} 10.3.4.1.1.hh
{overflow} 2.1.4.3.h
{overload} 4.5
parallel action 10.2.4.b
paranotion 1.1.4.2.a
{perform (an alignment)} 10.3.4.1.1.ff
{perform (an insertion)} 10.3.4.1.1.ee
{pattern} 10.3.4.1.1.cc
permanent relationship 2.1.2.a
{physical file} 10.3.1.5.cc
{picture} 10.3.4.1.1.cc
plain value 2.1.3.1.a
point 1.1.3.1.a
pragmatic remark 1.1.2.b
{pre-elaboration} 2.1.4.1.c
precede (in the textual order) 1.1.3.2.j
predicate 1.3.2.b
primal environ 2.2.2.a
process 10.2.4.b
produce 1.1.3.2.f
production rule 1.1.3.2.b
production tree 1.1.3.2.f
program in the strict language 1.1.1.b, 10.1.2.b
{property} 2.1.1.1.b, 3.0.2.b
protonotion 1.1.3.1.b
pseudo-comment 10.1.3.7
publication language 9.3.a
{random access} 10.3.1.3.ff
{reach} 3.0.2.b
real number 2.1.3.1.a
refer to 2.1.2.e, 2.1.3.2.a
reference language 9.3.a
relationship 2.1.2.a
{replicator} 10.3.4.1.1.dd
representation language 9.3.a
required 1.1.4.3.b
resume (an action) 2.1.4.3.g
routine 2.1.3.5.a
{rowing} 6
same as (of scopes) 2.1.2.f
scene 2.1.1.1.d
scope (of a value) 2.1.1.3.a
scope (of an environ) 2.1.1.3.b
{scratch (a file)} 10.3.1.4.hh
select (a 'TAG' selecting a field) 2.1.3.3.a
select (a 'TAG' selecting a multiple value) 2.1.3.4.k
select (a 'TAG' selecting a subname) 2.1.3.3.e
select (a field-selector selecting a field) 2.1.5.g
select (an index selecting a subname) 2.1.3.4.g
select (an index selecting an element) 2.1.3.4.a
select (a trim selecting a multiple value) 2.1.3.4.i
semantics 1.1.1.b
semicolon 1.1.3.1.a
sense of numerical analysis 2.1.3.1.e
{sequential access} 10.3.1.3.ff
serial action 2.1.4.2.a
simple substitute 1.1.3.3.d
size (of an arithmetic value) 2.1.3.1.b
small syntactic mark 1.1.3.1.a
smaller (descendent smaller than a production tree) 1.1.3.2.g
smaller than (of arithmetic values) 2.1.2.d, 2.1.3.1.e
{soft (position)} 6.1.1.b
{sort} 6
specify (a declarer specifying a mode) 4.6.2.d
{spelling (of a mode)} 2.1.1.2.b
standard environment 1.1.1, 10
{standard function} 10.2
{standard mode} 10.2
{standard operator} 10.2
{state} 10.3.1.3.b
{staticize (a picture)} 10.3.4.1.1.dd
stowed name 2.1.3.2.b
stowed value 2.1.1.1.a
straightening 10.3.2.3.c
strict language 1.1.1.b, 1.1.3.2.e, 10.1.2.b
{string} 8.3
{strong (position)} 6.1.1.b
structured value 2.1.3.3.a
sublanguage 2.2.2.c
subname 2.1.2.g
substitute consistently 1.1.3.4.e
substitute simply 1.1.3.3.d
superlanguage 2.2.2.c
{suppressed frame} 10.3.4.1.1.cc
symbol 1.1.3.1.f
{synchronization operation} 10.2
syntax
1.1.1
terminal metaproduction (of a metanotion) 1.1.3.3.c
terminal production (of a notion) 1.1.3.2.f
terminal production (of a production tree) 1.1.3.2.f
terminate (an action) 2.1.4.3.e
textual order 1.1.3.2.i
times (of arithmetic values) 2.1.3.1.e
transform 10.3.4.1.2.b
{transient name} 2.1.3.6.c
transitive relationship 2.1.2.a
{transput declaration} 10.2
{transput} 10.3
traverse 10.3.2.3.d
trim 2.1.3.4.h
truth value 2.1.3.1.f
typographical display feature 9.4.d
undefined 1.1.4.3.a
united from (of modes) 2.1.3.6.a
{uniting} 6
upper bound 2.1.3.4.b
vacant locale 2.1.1.1.b
value 2.1.1.1.a
variant (of a value) 4.4.2.c
variant of Algol 68 1.1.5.b
version (of an operator) 10.1.3.3
visible
1.1.3.2.h
void value 2.1.3.1.h
{voiding} 6
{weak (position)} 6.1.1.b
{well formed} 7.4
widenable to (an integer to a real number) 2.1.2.d, 2.1.3.1.e
{widening} 6
yield (of a scene) 2.1.2.b

{Denn eben, wo Begriffe fehlen,
Da stellt ein Wort zur rechten Zeit sich ein.
Faust, J.W. von Goethe.}

12.2. Paranotions

Given below are short paranotions representing the notions defined in this Report, with references to their hyper-rules.

after-specification 10.3.4.10.1.c
alignment 10.3.4.1.1.e
alignment-code 10.3.4.1.1.f
alternate-CHOICE-clause 3.4.1.d
assignation 5.2.1.1.a
bits-denotation 8.2.1.l
bits-pattern 10.3.4.7.1.a
boolean-choice-pattern 10.3.4.8.1.b
boolean-marker 10.3.4.4.1.b
boolean-pattern 10.3.4.4.1.a
boundscript 5.3.2.1.j
call 5.4.3.1.a
case-clause 3.4.1.p
case-part-of-CHOICE 3.4.1.i
cast 5.5.1.1.a
character-glyph 8.1.4.1.c
character-marker 10.3.4.6.1.b
choice-clause 3.4.1.n
chooser-CHOICE-clause 3.4.1.b
closed-clause 3.1.1.a
coercee 6.1.1.g
coercend 6.1.1.h
collateral-clause 3.3.1.a, d, e
collection 10.3.4.1.1.b
complex-marker 10.3.4.5.1.b
complex-pattern 10.3.4.5.1.a
conditional-clause 3.4.1.o
conformity-clause 3.4.1.q
constant 3.0.1.d
declaration 4.1.1.a
declarative 5.4.1.1.e
declarator 4.6.1.c, d, g, h, o, s
declarer 4.2.1.c, 4.4.1.b, 4.6.1.a, b
definition 4.1.1.d
denotation 8.1.0.1.a, 8.1.1.1.a, 8.1.2.1.a, 8.1.3.1.a, 8.1.4.1.a, 8.1.5.1.a, 8.2.1.a, b, c, 8.3.1.a
denoter 8.0.1.a
deprocedured-to-FORM 6.3.1.a
dereferenced-to-FORM 6.2.1.a
destination 5.2.1.1.b
digit-cypher 8.1.1.1.c
digit-marker 10.3.4.2.1.f
display 3.3.1.j
do-part 3.5.1.h
dyadic-operator 5.4.2.1.e
enquiry-clause 3.4.1.c
establishing-clause 3.2.1.i
exponent-marker 10.3.4.3.1.e
exponent-part 8.1.2.1.g
exponent-specification 10.3.4.10.1.d
expression 3.0.1.b
field-selector 4.8.1.f
fixed-point-numeral 8.1.1.1.b
floating-point-mould 10.3.4.3.1.c
floating-point-numeral 8.1.2.1.e
for-part 3.5.1.b
format-pattern 10.3.4.9.1.a
format-text 10.3.4.1.1.a
formula 5.4.2.1.d
fractional-part 8.1.2.1.d
frame 10.3.4.1.1.m
general-pattern 10.3.4.10.1.a
generator 5.2.3.1.a
go-to 5.4.4.1.b
hip 5.1.a
identifier-declaration 4.4.1.g
identity-declaration 4.4.1.a
identity-definition 4.4.1.c
identity-relation 5.2.2.1.a
identity-relator 5.2.2.1.b
in-part-of-CHOICE 3.4.1.f, g, h
in-CHOICE-clause 3.4.1.e
indexer 5.3.2.1.i
indicator 4.8.1.e
insertion 10.3.4.1.1.d
integral-choice-pattern 10.3.4.8.1.a
integral-mould 10.3.4.2.1.b
integral-part 8.1.2.1.c
integral-pattern 10.3.4.2.1.a
intervals 3.5.1.c
joined-label-definition 10.1.1.h
joined-portrait 3.3.1.b
jump 5.4.4.1.a
label-definition 3.2.1.c
literal 10.3.4.1.1.i
loop-clause 3.5.1.a
lower-bound 4.6.1.m
marker 10.3.4.1.1.n
mode-declaration 4.2.1.a
mode-definition 4.2.1.b
monadic-operator 5.4.2.1.f
nihil 5.2.4.1.a
operand 5.4.2.1.g
operation-declaration 4.5.1.a
operation-definition 4.5.1.c
other-string-item 8.1.4.1.d
other-PRAGMENT-item 9.2.1.d
parallel-clause 3.3.1.c
parameter 5.4.1.1.g, 5.4.3.1.c
parameter-definition 5.4.1.1.f
particular-postlude 10.1.1.i
particular-program 10.1.1.g
pattern 10.3.4.1.1.o
phrase 3.0.1.a
picture 10.3.4.1.1.c
plain-denotation 8.1.0.1.b
plan 4.5.1.b, 4.6.1.p
plusminus 8.1.2.1.j
point-marker 10.3.4.3.1.d
power-of-ten 8.1.2.1.i
praglit 10.3.4.8.1.c
pragment 9.2.1.a
preludes 10.1.1.b
priority-declaration 4.3.1.a
priority-definition 4.3.1.b
program 2.2.1.a
program-text 10.1.1.a
radix-digit 8.2.1.m
radix-marker 10.3.4.7.1.c
range 3.0.1.f
real-pattern 10.3.4.3.1.a
repeating-part 3.5.1.e
replicator 10.3.4.1.1.g
revised-lower-bound 5.3.2.1.g
routine-declarer 4.4.1.b
routine-plan 4.5.1.b
routine-text 5.4.1.1.a, b
row-display 3.3.1.i
row-rower 4.6.1.j, k, l
row-ROWS-rower 4.6.1.i
rowed-to-FORM 6.6.1.a
sample-generator 5.2.3.1.b
selection 5.3.1.1.a
serial-clause 3.2.1.a
series 3.2.1.b
sign-marker 10.3.4.2.1.e
sign-mould 10.3.4.2.1.c
skip 5.5.2.1.a
slice 5.3.2.1.a
softly-deprocedured-to-FORM 6.3.1.b
source 5.2.1.1.c
source-for-MODINE 4.4.1.d
specification 3.4.1.j, k
stagnant-part 8.1.2.1.f
statement 3.0.1.c
string 8.3.1.b
string-denotation 8.3.1.c
string-item 8.1.4.1.b
string-pattern 10.3.4.6.1.a
structure-display 3.3.1.h
subscript 5.3.2.1.e
suppression 10.3.4.1.1.l
symbol 9.1.1.h
system-task 10.1.1.e
tasks 10.1.1.d
times-ten-to-the-power-choice 8.1.2.1.h
token 9.1.1.g
trimmer 5.3.2.1.f
trimscript 5.3.2.1.h
unchanged-from-FORM 6.1.1.f
unit 3.2.1.d
unitary-clause 3.2.1.h
united-to-FORM 6.4.1.a
unsuppressible-literal 10.3.4.1.1.i
unsuppressible-replicator 10.3.4.1.1.h
unsuppressible-suppression 10.3.4.1.1.l
upper-bound 4.6.1.n
user-task 10.1.1.f
vacuum 3.3.1.k
variable 3.0.1.e
variable-declaration 4.4.1.e
variable-definition 4.4.1.f
variable-point-mould 10.3.4.3.1.b
variable-point-numeral 8.1.2.1.b
voided-to-FORM 6.7.1.a, b
while-do-part 3.5.1.f
while-part 3.5.1.g
widened-to-FORM 6.5.1.a, b, c, d
width-specification 10.3.4.10.1.b
zero-marker 10.3.4.2.1.d
ADIC-operand 5.4.2.1.c
CHOICE-again 9.1.1.c
CHOICE-finish 9.1.1.e
CHOICE-in 9.1.1.b
CHOICE-out 9.1.1.d
CHOICE-start 9.1.1.a
CHOICE-clause 3.4.1.a
COMMON-joined-definition 4.1.1.b, c
DYADIC-formula 5.4.2.1.a
EXTERNAL-prelude 10.1.1.c
FIELDS-definition-of-FIELD 4.6.1.f
FIELDS-portrait 3.3.1.f, g
FIELDS-portrayer-of-FIELDS1 4.6.1.e
FORM-coercee 6.1.1.a, b, c, d, e
FROBYT-part 3.5.1.d
INDICATOR 4.8.1.a, b
MOIDS-joined-declarer 4.6.1.t, u
MONADIC-formula 5.4.2.1.b
NOTETY-pack 1.3.3.d
NOTION-bracket 1.3.3.e
NOTION-list 1.3.3.c
NOTION-option 1.3.3.a
NOTION-sequence 1.3.3.b
NOTION-token 9.1.1.f
PARAMETERS 5.4.3.1.b
PARAMETERS-joined-declarer 4.6.1.q, r
PRAGMENT 9.2.1.b
PRAGMENT-item 9.2.1.c
QUALITY-FIELDS-field-selector 4.8.1.c, d
RADIX 8.2.1.d, e, f, g
RADIX-digit 8.2.1.h, i, j, k
RADIX-frame 10.3.4.7.1.b
ROWS-leaving-ROWSETY-indexer 5.3.2.1.b, c, d
TALLY-declarer 4.2.1.c
THING1-or-alternatively-THING2 1.3.3.f
UNSUPPRESSETY-literal 10.3.4.1.1.i
UNSUPPRESSETY-suppression 10.3.4.1.1.l
UNSUPPRESSETY-COMARK-frame 10.3.4.1.1.k
UNSUPPRESSETY-MARK-frame 10.3.4.1.1.j

12.3. Predicates

Given below are abbreviated forms of the predicates defined in this Report.

'and' 1.3.1.c, e
'balances' 3.2.1.f, g
'begins with' 1.3.1.h, i, j
'coincides with' 1.3.1.k, l
'contains' 1.3.1.m, n
'counts' 4.3.1.c, d
'deflexes to' 4.7.1.a, b, c, d, e
'deprefs to firm' 7.1.1.n
'develops from' 7.3.1.c
'equivalent' 7.3.1.a, b, d, e, f, g, h, i, j, k, q
'false' 1.3.1.b
'firmly related' 7.1.1.k
'identified in' 7.2.1.a
'incestuous' 4.7.1.f
'independent' 7.1.1.a, b, c, d
'is' 1.3.1.g
'is derived from' 5.3.1.1.b, c
'is firm' 7.1.1.l, m
'like' 5.4.1.1.c, d
'may follow' 3.4.1.m
'number equals' 7.3.1.o, p
'or' 1.3.1.d, f
'ravels to' 4.7.1.g
'related' 7.1.1.e, f, g, h, i, j
'resides in' 7.2.1.b, c
'shields' 7.4.1.a, b, c, d
'subset of' 7.3.1.l, m, n
'true' 1.3.1.a
'unites to' 6.4.1.b

12.4. Index to the standard prelude

< 10.2.3.0.a, 10.2.3.3.a, 10.2.3.5.c, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.9.a, 10.2.3.10.a, g, h
<= 10.2.3.0.a, 10.2.3.3.b, 10.2.3.4.b, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.8.e, 10.2.3.9.a, 10.2.3.10.b, g, h
+ 10.2.3.0.a, 10.2.3.3.i, j, 10.2.3.4.i, j, 10.2.3.5.a, b, 10.2.3.6.b, 10.2.3.7.j, k, p, q, r, s, 10.2.3.10.i, j, k
+:= 10.2.3.0.a, 10.2.3.11.d, e, f, o, p, q, s
+=: 10.2.3.0.a, 10.2.3.11.r, t
10.2.3.0.a, 10.2.3.3.u, 10.2.3.4.s, 10.2.3.5.e, f
+* 10.2.3.0.a, 10.2.3.3.u, 10.2.3.4.s, 10.2.3.5.e, f
& 10.2.3.0.a, 10.2.3.2.b, 10.2.3.8.d
10.2.3.0.a, 10.2.3.8.h
10.2.3.0.a, 10.2.3.3.e, 10.2.3.4.e, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.8.f, 10.2.3.9.a, 10.2.3.10.e, g, h
10.2.3.0.a, 10.2.3.3.b, 10.2.3.4.b, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.8.e, 10.2.3.9.a, 10.2.3.10.b, g, h
10.2.3.0.a, 10.2.3.2.e, 10.2.3.3.d, 10.2.3.4.d, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.7.g, u, v, w, x, 10.2.3.8.b, 10.2.3.9.a, 10.2.3.10.d, g, h
10.2.3.0.a, 10.2.3.3.u, 10.2.3.4.s, 10.2.3.5.e, f
÷ 10.2.3.0.a, 10.2.3.3.m
÷x 10.2.3.0.a, 10.2.3.3.n
÷x:= 10.2.3.0.a, 10.2.3.11.k
÷* 10.2.3.0.a, 10.2.3.3.n
÷*:= 10.2.3.0.a, 10.2.3.11.k
÷:= 10.2.3.0.a, 10.2.3.11.j
x 10.2.3.0.a, 10.2.3.3.l, 10.2.3.4.l, 10.2.3.5.a, b, 10.2.3.7.l, p, q, r, s, 10.2.3.10.l, m, n, o
x:= 10.2.3.0.a, 10.2.3.11.g, h, i, n, o, p, u
~ 10.2.3.2.c, 10.2.3.8.m
^ 10.2.3.0.a, 10.2.3.3.p, 10.2.3.5.g, 10.2.3.7.t, 10.2.3.8.g
* 10.2.3.0.a, 10.2.3.3.l, 10.2.3.4.l, 10.2.3.5.a, b, 10.2.3.7.l, p, q, r, s, 10.2.3.10.l, m, n, o
** 10.2.3.0.a, 10.2.3.3.p, 10.2.3.5.g, 10.2.3.7.t
*:= 10.2.3.0.a, 10.2.3.11.g, h, i, n, o, p, u
~_ 10.2.3.2.c, 10.2.3.8.m
- 10.2.3.0.a, 10.2.3.3.g, h, 10.2.3.4.g, h, 10.2.3.5.a, b, 10.2.3.7.h, i, p, q, r, s
-:= 10.2.3.0.a, 10.2.3.11.a, b, c, n, o, p
/ 10.2.3.0.a, 10.2.3.3.o, 10.2.3.4.m, 10.2.3.5.a, b, 10.2.3.7.m, p, q, r, s
/:= 10.2.3.0.a, 10.2.3.11.l, m, n, o, p
/= 10.2.3.0.a, 10.2.3.2.e
, 10.2.3.3.d, 10.2.3.4.d, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.7.g, u, v, w, x, 10.2.3.8.b, 10.2.3.9.a, 10.2.3.10.d, g, h
% 10.2.3.0.a, 10.2.3.3.m
%x 10.2.3.0.a, 10.2.3.3.n
%x:= 10.2.3.0.a, 10.2.3.11.k
%* 10.2.3.0.a, 10.2.3.3.n
%*:= 10.2.3.0.a, 10.2.3.11.k
%:= 10.2.3.0.a, 10.2.3.11.j
> 10.2.3.0.a, 10.2.3.3.f, 10.2.3.4.f, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.9.a, 10.2.3.10.f, g, h
>= 10.2.3.0.a, 10.2.3.3.e, 10.2.3.4.e, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.8.f, 10.2.3.9.a, 10.2.3.10.e, g, h
= 10.2.3.0.a, 10.2.3.2.d, 10.2.3.3.c, 10.2.3.4.c, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.7.f, u, v, w, x, 10.2.3.8.a, 10.2.3.9.a, 10.2.3.10.c, g, h
ABS 10.2.1.n, 10.2.3.2.f, 10.2.3.3.k, 10.2.3.4.k, 10.2.3.7.c, 10.2.3.8.i
AND 10.2.3.0.a, 10.2.3.2.b, 10.2.3.8.d
ARG 10.2.3.7.d
BIN 10.2.3.8.j
BITS 10.2.2.g
BOOL 10.2.2.b
BYTES 10.2.2.h
CHANNEL 10.3.1.2.a
CHAR 10.2.2.e
COMPL 10.2.2.f
CONJ 10.2.3.7.e
DIVAB 10.2.3.0.a, 10.2.3.11.l, m, n, o, p
DOWN 10.2.3.0.a, 10.2.3.8.h, 10.2.4.d
ELEM 10.2.3.0.a, 10.2.3.8.k, 10.2.3.9.b
ENTIER 10.2.3.4.r
EQ 10.2.3.0.a, 10.2.3.2.d, 10.2.3.3.c, 10.2.3.4.c, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.7.f, u, v, w, x, 10.2.3.8.a, 10.2.3.9.a, 10.2.3.10.c, g, h
FILE 10.3.1.3.a
FORMAT 10.3.5.a
GE 10.2.3.0.a, 10.2.3.3.e, 10.2.3.4.e, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.8.f, 10.2.3.9.a, 10.2.3.10.e, g, h
GT 10.2.3.0.a, 10.2.3.3.f, 10.2.3.4.f, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.9.a, 10.2.3.10.f, g, h
I 10.2.3.0.a, 10.2.3.3.u, 10.2.3.4.s, 10.2.3.5.e, f
IM 10.2.3.7.b
INT 10.2.2.c
LE 10.2.3.0.a, 10.2.3.3.b, 10.2.3.4.b, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.8.e, 10.2.3.9.a, 10.2.3.10.b, g, h
LENG 10.2.3.3.q, 10.2.3.4.n, 10.2.3.7.n, 10.2.3.8.n, 10.2.3.9.d
LEVEL 10.2.4.b, c
LT 10.2.3.0.a, 10.2.3.3.a, 10.2.3.4.a, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.9.a, 10.2.3.10.a, g, h
LWB 10.2.3.0.a, 10.2.3.1.b, d
MINUSAB 10.2.3.0.a, 10.2.3.11.a, b, c, n, o, p
MOD 10.2.3.0.a, 10.2.3.3.n
MODAB 10.2.3.0.a, 10.2.3.11.k
NE 10.2.3.0.a, 10.2.3.2.e, 10.2.3.3.d, 10.2.3.4.d, 10.2.3.5.c, d, 10.2.3.6.a, 10.2.3.7.g, u, v, w, x, 10.2.3.8.b, 10.2.3.9.a, 10.2.3.10.d, g, h
NOT 10.2.3.2.c, 10.2.3.8.m
ODD 10.2.3.3.s
OR 10.2.3.0.a, 10.2.3.2.a, 10.2.3.8.c
OVER 10.2.3.0.a, 10.2.3.3.m
OVERAB 10.2.3.0.a, 10.2.3.11.j
PLUSAB 10.2.3.0.a, 10.2.3.11.d, e, f, n, o, p, q, s
PLUSTO 10.2.3.0.a, 10.2.3.11.r, t
RE 10.2.3.7.a
REAL 10.2.2.d
REPR 10.2.1.o
ROUND 10.2.3.4.p
SEMA 10.2.4.a
SHL 10.2.3.0.a, 10.2.3.8.g
SHORTEN 10.2.3.3.r, 10.2.3.4.o, 10.2.3.7.o, 10.2.3.8.o, 10.2.3.9.e
SHR 10.2.3.0.a, 10.2.3.8.h
SIGN 10.2.3.3.t, 10.2.3.4.q
STRING 10.2.2.i
TIMESAB 10.2.3.0.a, 10.2.3.11.g, h, i, n, o, p, u
UP 10.2.3.0.a, 10.2.3.3.p, 10.2.3.5.g, 10.2.3.7.t, 10.2.3.8.g, 10.2.4.e
UPB 10.2.3.0.a, 10.2.3.1.c, e
VOID 10.2.2.a
arccos 10.2.3.12.f
arcsin 10.2.3.12.h
arctan 10.2.3.12.j
associate 10.3.1.4.e
backspace 10.3.1.6.b
bin possible 10.3.1.3.d
bits lengths 10.2.1.h
bits pack 10.2.3.8.l
bits shorths 10.2.1.i
bits width 10.2.1.j
blank 10.2.1.u
bytes lengths 10.2.1.k
bytes pack 10.2.3.9.c
bytes shorths 10.2.1.l
bytes width 10.2.1.m
chan 10.3.1.3.i
char in string 10.3.2.1.l
char number 10.3.1.5.a
close 10.3.1.4.n
compressible 10.3.1.3.e
cos 10.2.3.12.e
create 10.3.1.4.c
errorchar 10.2.1.t
estab possible 10.3.1.2.c
establish 10.3.1.4.b
exp 10.2.3.12.c
exp width 10.3.2.1.o
fixed 10.3.2.1.c
flip 10.2.1.r
float 10.3.2.1.d
flop 10.2.1.s
get 10.3.3.2.a
get bin 10.3.6.2.a
get possible 10.3.1.3.b
getf 10.3.5.2.a
int shorths 10.2.1.b
int width 10.3.2.1.m
last random 10.5.1.a
line number 10.3.1.5.b
ln 10.2.3.12.d
lock 10.3.1.4.o
make conv 10.3.1.3.j
make term 10.3.1.3.k
max abs char 10.2.1.p
max int 10.2.1.c
max real 10.2.1.f
newline 10.3.1.6.c
newpage 10.3.1.6.d
next random 10.2.3.12.k
null character 10.2.1.q
on char error 10.3.1.3.r
on format end 10.3.1.3.p
on line end 10.3.1.3.o
on logical file end 10.3.1.3.l
on page end 10.3.1.3.n
on physical file end 10.3.1.3.m
on value error 10.3.1.3.q
open 10.3.1.4.d
page number 10.3.1.5.c
pi 10.2.3.12.a
print 10.5.1.d
printf 10.5.1.f
put 10.3.3.1.a
put bin 10.3.6.1.a
put possible 10.3.1.3.c
putf 10.3.5.1.a
random 10.5.1.b
read 10.5.1.e
read bin 10.5.1.i
readf 10.5.1.g
real lengths 10.2.1.d
real shorths 10.2.1.e
real width 10.3.2.1.n
reidf 10.3.1.3.s
reidf possible 10.3.1.3.h
reset 10.3.1.6.j
reset possible 10.3.1.3.f
scratch 10.3.1.4.p
set 10.3.1.6.i
set char number 10.3.1.6.k
set possible 10.3.1.3.g
sin 10.2.3.12.g
small real 10.2.1.g
space 10.3.1.6.a
sqrt 10.2.3.12.b
stand back 10.5.1.c
stand back channel 10.3.1.2.g
stand in 10.5.1.c
stand in channel 10.3.1.2.e
stand out 10.5.1.c
stand out channel 10.3.1.2.f
standconv 10.3.1.2.d
stop 10.5.2.a
tan 10.2.3.12.i
whole 10.3.2.1.b
write 10.5.1.d
write bin 10.5.1.h
writef 10.5.1.f
L BITS 10.2.2.g
L BYTES 10.2.2.h
L COMPL 10.2.2.f
L INT 10.2.2.c
L REAL 10.2.2.d
L arccos 10.2.3.12.f
L arcsin 10.2.3.12.h
L arctan 10.2.3.12.j
L bits pack 10.2.3.8.l
L bits width 10.2.1.j
L bytes pack 10.2.3.9.c
L bytes width 10.2.1.m
L cos 10.2.3.12.e
L exp 10.2.3.12.c
L exp width 10.3.2.1.o
L int width 10.3.2.1.m
L last random 10.5.1.a
L ln 10.2.3.12.d
L max int 10.2.1.c
L max real 10.2.1.f
L next random 10.2.3.12.k
L pi 10.2.3.12.a
L random 10.5.1.b
L real width 10.3.2.1.n
L sin 10.2.3.12.g
L small real 10.2.1.g
L sqrt 10.2.3.12.b
L tan 10.2.3.12.i
? BEYOND 10.3.1.1.d
? BFILE 10.3.1.1.e
? BOOK 10.3.1.1.a
? COLLECTION 10.3.5.a
? COLLITEM 10.3.5.a
? CONV 10.3.1.2.b
? CPATTERN 10.3.5.a
? FLEXTEXT 10.3.1.1.b
? FPATTERN 10.3.5.a
? FRAME 10.3.5.a
? GPATTERN 10.3.5.a
? INSERTION 10.3.5.a
? INTYPE 10.3.2.2.d
? NUMBER 10.3.2.1.a
? OUTTYPE 10.3.2.2.b
? PATTERN 10.3.5.a
? PICTURE 10.3.5.a
? PIECE 10.3.5.a
? POS 10.3.1.1.c
? ROWS 10.2.3.1.a
? SFRAME 10.3.5.e
? SIMPLIN 10.3.2.2.c
? SIMPLOUT 10.3.2.2.a
? SINSERT 10.3.5.c
? STRAIGHTIN 10.3.2.3.b
? STRAIGHTOUT 10.3.2.3.a
? TEXT 10.3.1.1.b
? alignment 10.3.5.i
? associate format 10.3.5.k
? bfileprotect 10.3.1.1.h
? book bounds 10.3.1.5.e
? chainbfile 10.3.1.1.f
? char dig 10.3.2.1.k
? check pos 10.3.3.2.c
? current pos 10.3.1.5.d
? dig char 10.3.2.1.h
? do fpattern 10.3.5.j
? edit string 10.3.5.1.b
? false 10.3.1.4.i
? file available 10.3.1.4.f
? from bin 10.3.6.b
? get char 10.3.3.2.b
? get good file 10.3.1.6.g
? get good line 10.3.1.6.e
? get good page 10.3.1.6.f
? get insertion 10.3.5.h
? get next picture 10.3.5.b
? gremlins 10.4.1.a
? idf ok 10.3.1.4.g
? indit string 10.3.5.2.b
? line ended 10.3.1.5.f
? lockedbfile 10.3.1.1.g
? logical file ended 10.3.1.5.i
? match 10.3.1.4.h
? next pos 10.3.3.1.c
? page ended 10.3.1.5.g
? physical file ended 10.3.1.5.h
? put char 10.3.3.1.b
? put insertion 10.3.5.g
? set bin mood 10.3.1.4.m
? set char mood 10.3.1.4.l
? set mood 10.3.1.6.h
? set read mood 10.3.1.4.k
? set write mood 10.3.1.4.j
? standardize 10.3.2.1.g
? staticize frames 10.3.5.f
? staticize insertion 10.3.5.d
? string to L int 10.3.2.1.i
? string to L real 10.3.2.1.j
? subfixed 10.3.2.1.f
? subwhole 10.3.2.1.e
? to bin 10.3.6.a
? undefined 10.3.1.4.a
? L standardize 10.3.2.1.g

12.5. Alphabetic listing of metaproduction rules

ABC {942L} :: a ; b ; c ; d ; e ; f ; g ; h ; i ; j ; k ; l ; m ; n ; o ; p ; q ; r ; s ; t ; u ; v ; w ; x ; y ; z.
ADIC {542C} :: DYADIC ; MONADIC.
ALPHA {13B} :: a ; b ; c ; d ; e ; f ; g ; h ; i ; j ; k ; l ; m ; n ; o ; p ; q ; r ; s ; t ; u ; v ; w ; x ; y ; z.
BECOMESETY {942J} :: cum becomes ; cum assigns to ; EMPTY.
BITS {65A} :: structured with row of boolean field SITHETY letter aleph mode.
BYTES {65B} :: structured with row of character field SITHETY letter aleph mode.
CASE {34B} :: choice using integral ; choice using UNITED.
CHOICE {34A} :: choice using boolean ; CASE.
COLLECTION {A341C} :: union of PICTURE COLLITEM mode.
COLLITEM {A341D} :: structured with INSERTION field letter i digit one
procedure yielding integral field letter r letter e letter p
integral field letter p
INSERTION field letter i digit two mode.
COMARK {A341N} :: zero ; digit ; character.
COMMON {41A} :: mode ; priority ; MODINE identity ; reference to MODINE variable ; MODINE operation ; PARAMETER ; MODE FIELDS.
COMORF {61G} :: NEST assignation ; NEST identity relation ;
NEST LEAP generator ; NEST cast ; NEST denoter ; NEST format text.

CPATTERN {A341I} :: structured with INSERTION field letter i
integral field letter t letter y letter p letter e
row of INSERTION field letter c mode.

DEC {123E} :: MODE TAG ; priority PRIO TAD ; MOID TALLY TAB ; DUO TAD ; MONO TAM.
DECS {123D} :: DEC ; DECS DEC.
DECSETY {123C} :: DECS ; EMPTY.
DEFIED {48B} :: defining ; applied.
DIGIT {942C} :: digit zero ; digit one ; digit two ; digit three ;
digit four ; digit five ; digit six ; digit seven ; digit eight ; digit nine.

DOP {942M*} :: DYAD ; DYAD cum NOMAD.
DUO {123H} :: procedure with PARAMETER1 PARAMETER2 yielding MOID.
DYAD {942G} :: MONAD ; NOMAD.
DYADIC {542A} :: priority PRIO.
EMPTY {12G} :: .
ENCLOSED {122A} :: closed ; collateral ; parallel ; CHOICE ; loop.
EXTERNAL {A1A} :: standard ; library ; system ; particular.
FIELD {12J} :: MODE field TAG.
FIELDS {12I} :: FIELD ; FIELDS FIELD.
FIRM {61B} :: MEEK ; united to.
FIVMAT {A341L} :: mui definition of structured with row of
structured with integral field letter c letter p
integral field letter c letter o letter u letter n letter t
integral field letter b letter p row of union of structured
with union of PATTERN CPATTERN
structured with INSERTION field letter i
procedure yielding mui application field
letter p letter f mode GPATTERN void mode field letter p
INSERTION field letter i mode COLLITEM mode field
letter c mode field letter aleph mode.

FLEXETY {12K} :: flexible ; EMPTY.
FORM {61E} :: MORF ; COMORF.
FORMAT {A341A} :: structured with row of PIECE field letter aleph mode.
FPATTERN {A341J} :: structured with INSERTION field letter i
procedure yielding FIVMAT field letter p letter f mode.

FRAME {A341H} :: structured with INSERTION field letter i
procedure yielding integral field letter r letter e letter p
boolean field letter s letter u
letter p letter p
character field letter m letter a letter r letter k
letter e letter r mode.

FROBYT {35A} :: from ; by ; to.
GPATTERN {A341K} ::
structured with INSERTION field letter i
row of procedure yielding integral field
letter s letter p letter e letter c mode.

HEAD {73B} :: PLAIN ; PREF ; structured with ; FLEXETY ROWS of ; procedure with ; union of ; void.
INDICATOR {48A} :: identifier ; mode indication ; operator.
INSERTION {A341E} :: row of structured with procedure yielding integral field
letter r letter e letter p
union of row of character character mode field letter s letter a mode.

INTREAL {12C} :: SIZETY integral ; SIZETY real.
LAB {123K} :: label TAG.
LABS {123J} :: LAB ; LABS LAB.
LABSETY {123I} :: LABS ; EMPTY.
LAYER {123B} :: new DECSETY LABSETY.
LEAP {44B} :: local ; heap ; primal.
LENGTH {65D} :: letter l letter o letter n letter g.
LENGTHETY {65F} :: LENGTH LENGTHETY ; EMPTY.
LETTER {942B} :: letter ABC ; letter aleph ; style TALLY letter ABC.
LONGSETY {12E} :: long LONGSETY ; EMPTY.
MARK {A341M} :: sign ; point ; exponent ; complex ; boolean.
MEEK {61C} :: unchanged from ; dereferenced to ; deprocedured to.
MODE {12A} :: PLAIN ; STOWED ; REF to MODE ; PROCEDURE ; UNITED ; MU definition of MODE ; MU application.
MODINE {44A} :: MODE ; routine.
MOID {12R} :: MODE ; void.
MOIDS {46C} :: MOID ; MOIDS MOID.
MOIDSETY {47C} :: MOIDS ; EMPTY.
MONAD {942H} :: or ; and ; ampersand ; differs from ; is at most ; is at least ; over ; percent ; window ; floor ; ceiling ; plus i times ; not ; tilde ; down ; up ; plus ; minus ; style TALLY monad.
MONADIC {542B} :: priority iii iii iii i.
MONO {123G} :: procedure with PARAMETER yielding MOID.
MOOD {12U} :: PLAIN ; STOWED ; reference to MODE ; PROCEDURE ; void.
MOODS {12T} :: MOOD ; MOODS MOOD.
MOODSETY {47B} :: MOODS ; EMPTY.
MORF {61F} :: NEST selection ; NEST slice ; NEST routine text ; NEST ADIC formula ; NEST call ; NEST applied identifier with TAG.
MU {12V} :: muTALLY.
NEST {123A} :: LAYER ; NEST LAYER.
NOMAD {942I} :: is less than ; is greater than ; divided by ; equals ; times ; asterisk.
NONPREF {71B} :: PLAIN ; STOWED ; procedure with PARAMETERS yielding MOID ; UNITED ; void.
NONPROC {67A} :: PLAIN ; STOWED ; REF to NONPROC ; procedure with PARAMETERS yielding MOID ; UNITED.
NONSTOWED {47A} :: PLAIN ; REF to MODE ; PROCEDURE ; UNITED ; void.
NOTETY {13C} :: NOTION ; EMPTY.
NOTION {13A} :: ALPHA ; NOTION ALPHA.
NUMERAL {810B*} :: fixed point numeral ; variable point numeral ; floating point numeral.
PACK {31B} :: STYLE pack.
PARAMETER {12Q} :: MODE parameter.
PARAMETERS {12P} :: PARAMETER ; PARAMETERS PARAMETER.
PARAMETY {12O} :: with PARAMETERS ; EMPTY.
PART {73E} :: FIELD ; PARAMETER.
PARTS {73D} :: PART ; PARTS PART.
PATTERN {A341G} :: structured with
integral field letter t letter y letter p letter e
row of FRAME field
letter f letter r letter a letter m letter e letter s mode.

PICTURE {A341F} :: structured with union of PATTERN CPATTERN FPATTERN GPATTERN void mode field letter p
INSERTION field letter i mode.

PIECE {A341B} :: structured with integral field letter c letter p
integral field letter c letter o letter u letter n letter t
integral field letter b letter p
row of COLLECTION field letter c mode.

PLAIN {12B} :: INTREAL ; boolean ; character.
PRAGMENT {92A} :: pragmat ; comment.
PRAM {45A} :: DUO ; MONO.
PREF {71A} :: procedure yielding ; REF to.
PREFSETY {71C*} :: PREF PREFSETY ; EMPTY.
PRIMARY {5D} :: slice coercee ; call coercee ; cast coercee ; denoter coercee ;
format text coercee ; applied identifier with TAG coercee ; ENCLOSED clause.

PRIO {123F} :: i ; ii ; iii ; iii i ; iii ii ; iii iii ; iii iii i ; iii iii ii ; iii iii iii.
PROCEDURE {12N} :: procedure PARAMETY yielding MOID.
PROP {48E} :: DEC ; LAB ; FIELD.
PROPS {48D} :: PROP ; PROPS PROP.
PROPSETY {48C} :: PROPS ; EMPTY.
QUALITY {48F} :: MODE ; MOID TALLY ; DYADIC ; label ; MODE field.
RADIX {82A} :: radix two ; radix four ; radix eight ; radix sixteen.
REF {12M} :: reference ; transient reference.
REFETY {531A} :: REF to ; EMPTY.
REFLEXETY {531B} :: REF to ; REF to flexible ; EMPTY.
ROWS {12L} :: row ; ROWS row.
ROWSETY {532A} :: ROWS ; EMPTY.
SAFE {73A} :: safe ; MU has MODE SAFE ; yin SAFE ; yang SAFE ; remember MOID1 MOID2 SAFE.
SECONDARY {5C} :: LEAP generator coercee ; selection coercee ; PRIMARY.
SHORTH {65E} :: letter s letter h letter o letter r letter t.
SHORTHETY {65G} :: SHORTH SHORTHETY ; EMPTY.
SHORTSETY {12F} :: short SHORTSETY ; EMPTY.
SITHETY {65C} :: LENGTH LENGTHETY ; SHORTH SHORTHETY ; EMPTY.
SIZE {810A} :: long ; short.
SIZETY {12D} :: long LONGSETY ; short SHORTSETY ; EMPTY.
SOFT {61D} :: unchanged from ; softly deprocedured to.
SOID {31A} :: SORT MOID.
SOME {122B} :: SORT MOID NEST.
SORT {122C} :: strong ; firm ; meek ; weak ; soft.
STANDARD {942E} :: integral ; real ; boolean ; character ; format ; void ; complex ; bits ; bytes ; string ; sema ; file ; channel.
STOP {A1B} :: label letter s letter t letter o letter p.
STOWED {12H} :: structured with FIELDS mode ; FLEXETY ROWS of MODE.
STRONG {61A} :: FIRM ; widened to ; rowed to ; voided to.
STYLE {133A} :: brief ; bold ; style TALLY.
TAB {942D} :: bold TAG ; SIZETY STANDARD.
TAD {942F} :: bold TAG ; DYAD BECOMESETY ; DYAD cum NOMAD BECOMESETY.
TAG {942A} :: LETTER ; TAG LETTER ; TAG DIGIT.
TAILETY {73C} :: MOID ; FIELDS mode ; PARAMETERS yielding MOID ; MOODS mode ; EMPTY.
TALLETY {542D} :: TALLY ; EMPTY.
TALLY {12W} :: i ; TALLY i.
TAM {942K} :: bold TAG ; MONAD BECOMESETY ; MONAD cum NOMAD BECOMESETY.
TAO {45B} :: TAD ; TAM.
TAX {48G} :: TAG ; TAB ; TAD ; TAM.
TERTIARY {5B} :: ADIC formula coercee ; nihil ; SECONDARY.
THING {13D} :: NOTION ; (NOTETY1) NOTETY2 ; THING (NOTETY1) NOTETY2.
TYPE {A341P} :: integral ; real ; boolean ; complex ; string ; bits ; integral choice ; boolean choice ; format ; general.
UNIT {5A} :: assignation coercee ; identity relation coercee ; routine text coercee ; jump ; skip ; TERTIARY.
UNITED {12S} :: union of MOODS mode.
UNSUPPRESSETY {A341O} :: unsuppressible ; EMPTY.
VICTAL {46A} :: VIRACT ; formal.
VIRACT {46B} :: virtual ; actual.
WHETHER {13E} :: where ; unless.


«Table of contents»

Appendix

Appendix. Specification of partial parametrization proposal

by C.H. Lindsey (University of Manchester)

{This appendix is not a part of the Algol 68 Revised Report, and is reproduced with kind permission of C.H. Lindsey.
Original publication Algol Bulletin 39.3.1 pages 6-9.}

The following specification has been released by the IFIP Working Group 2.1 Standing subcommittee on Algol 68 Support, with the authorization of the Working Group. This proposal has been scrutinized to ensure that

  1. it is strictly upwards-compatible with Algol 68,
  2. it is consistent with the philosophy and orthogonal framework of that language, and
  3. it fills a clearly discernible gap in the expressive power of that language.

In releasing this extension, the intention is to encourage implementers experimenting with features similar to those described below to use the formulation here given, so as to avoid proliferation of dialects.

{{Although routines are values in Algol 68, and can therefore be yielded by other routines, the practical usefulness of this facility is limited by scope restrictions. Consider:

PROC f = (REAL x) PROC (REAL) REAL: (REAL y) REAL: x + y;
PROC (REAL) REAL g := f (3);
x := g (4)

This attempts to assign to g the routine "add 3". It does not work because the body of the routine is still fundamentally the routine-text (REAL y) REAL : x + y which expects to find the value x (i.e. 3) on the stack in the form of an actual-parameter of f, and by this time f is finished with and its stack level has disappeared. The problem arises whenever a routine-text uses identifiers declared globally to itself and the limitation is expressed in the Report by making the scope of a routine dependent on its necessary environ (7.2.2.c). Here is an attempt at functional composition which fails to work for the same reason:

PROC compose = (PROC (REAL) REAL f, g) PROC (REAL) REAL: (REAL x) REAL:  f (g (x));  
PROC (REAL) REAL sex = compose (sqrt, exp)

Clearly, if the restriction is to be lifted, a routine value has to have associated with it copies of these global values. Unfortunately, their number is in general indeterminable at compile time, and so the implementation of such values must be similar to that of multiple values referred to by flexible names (2.1.3.4.f) requiring, in most implementations, the use of the heap.

In this variant, all the intended global values appear to the routine-text as its own formal-parameters. At each call, some or all of these parameters are provided with actual values, resulting in a routine with that number of parameters fewer. Ultimately (possibly after several calls) a routine without parameters is obtained and, if the context so demands, deproceduring can now take place. Thus, all calls in the original language turn out to be parametrizations followed by immediate deproceduring, but their effect is the same. Here are some examples:

1) PROC f = (REAL x, y) x + y; PROC (REAL) REAL g := f (3, ); x := g (4) #  or x := f (3, ) (4) #
2) PROC compose = (PROC (REAL) REAL f, g, REAL x) REAL; f (g (x)); 
PROC (REAL) REAL sex = compose (sqrt, exp, )
3) OP ↑ = (PROC (REAL) REAL a, INT b) PROC (REAL) REAL:
     ( (PROC (REAL) REAL a, INT b, REAL p) REAL:
        (REAL x := 1; TO b DO x *:= a (p) OD; x )) (a, b, );
   REAL theta; print ( (cos ↑ 2) (theta) + (sin ↑ 2) (theta))
}}

{{A routine now includes an extra locale.}}

2.1.3.5. Routines

a) A "routine" is a value composed of a routine-text {5.4.1.1.a,b}, an environ {2.1.1.1.c} and a locale {2.1.1.1.b}. {The locale corresponds to a 'DECSETY' reflecting the formal-parameters, if any, of the routine-text.}
b) The mode of a routine is some 'PROCEDURE'.
c) The scope of a routine is the newest of the scopes of its environ and of the values, if any, accessed {2.1.2.c} inside its locale.

{{A routine-text yields the new style of routine.}}

5.4.1.2. Semantics

The yield of a routine-text T, in an environ E, is the routine composed of

  1. T,
  2. the environ necessary for {7.2.2.c} T in E, and
  3. a locale corresponding to 'DECS2' if T has a declarative-defining-new-DECS2-brief-pack, and to 'EMPTY' otherwise.

{{Most of the remaining changes to the Report needed to incorporate this facility are in section 5.4.3 (calls).}}

5.4.3. Calls (with partial parametrization)

{A call is used to provide actual-parameters to match some or all of the formal-parameters of a routine. It yields a routine with correspondingly fewer formal-parameters or with none at all, in which case the yield is usually subject to deproceduring (6.3).

{Examples:

y := sin (x) • 
PROC REAL ncossini = (p | ncos | nsin) (i) •  
print ( (set char number ( ,  5), x)).}
}

5.4.3.1 Syntax

A) PARAMSETY :: PARAMETERS ; EMPTY.

a) procedure yielding MOID NEST call {5D} : meek procedure with PARAMETERS1 yielding MOID NEST PRIMARY {5D} , actual NEST PARAMETERS1 leaving EMPTY {c,d,e}brief pack.
b) procedure with PARAMETERS2 yielding MOID NEST call {5D} : meek procedure with PARAMETERS1 yielding MOID NEST PRIMARY {5D} , actual NEST PARAMETERS1 leaving PARAMETERS2 {c,d,e,f}brief pack.
c) actual NEST PARAMETER PARAMETERS leaving PARAMSETY1 PARAMSETY2 {a,b,c} : actual NEST PARAMETER leaving PARAMSETY1 {d,e}, and also {94f} token, actual NEST PARAMETERS leaving PARAMSETY2 {c,d,e}.
d) actual NEST MODE parameter leaving EMPTY {a,b,c} : strong MODE NEST unit {32d} .
e) actual NEST PARAMETER leaving PARAMETER {a,b,c} : EMPTY.
f) * actual MODE parameter : actual NEST MODE parameter leaving EMPTY {d}.
g) * dummy parameter : actual NEST PARAMETER leaving PARAMETER {e}.

{Examples:

a) set char number (stand out, 5)      
b) set char number ( , 5)   
c) , 5
d) 5
}

5.4.3.2. Semantics

a1) The yield W of a call C, in an environ E, is determined as follows:
• let R {a routine} and V1, ... , Vn be the {collateral} yields of the PRIMARY of C, in E, and of the constituent actual- and dummy-parameters of C, in an environ E1 established {locally, see 3.2.2.b} around E, where the yield of a dummy-parameter is "absent";
W is {the routine which is} the yield of the "parametrization" {a2} of R with V1, ... , Vn;
• except where C is the constituent call of a deprocedured-to-MOID-call {6.3.1.a}, it is required that W be not newer in scope than E {; thus, PROC (CHAR, STRING) BOOL cs = char in string ( , LOC INT, ) is undefined but q := char in string ("A", LOC INT, s) is not}.
a2) The yield W of the "parametrization" of a routine R0 with values V1, ... , Vn is determined as follows:
• let T0, E0 and L0 be, respectively, the routine-text, the environ and the locale of R0, and let L0 correspond {2.1.1.1.b} to some 'DECS0';
• let L1 be a new locale corresponding to 'DECS0', and let the value, if any, accessed by any 'DEC0' inside L0 be accessed also by that 'DEC0' inside L1;
• let 'DECS1' be a sequence composed of all those 'DEC0's enveloped by 'DECS0' which have not {yet} been made to access values inside L1, taken in their order within 'DECS0';
For i = 1, ... , n, If Vi is not absent, {see a1} , then the i-th 'DEC1' enveloped by 'DECS1' is made to access Vi inside L1;
otherwise, the i-th 'DEC1' still does not access anything;
W is the routine composed of T0, E0 and L1.

{A routine may be parametrized in several stages. Upon each occasion the yields of the new actual-parameters are made to be accessed inside its locale and the scope of the routine becomes the newest of its original scope and the scopes of those yields.}

b) The yield W of the "calling" of a routine R0 in an environ E1 {see 5.4.2.2 and 6.3.2} is determined as follows:
• let T0, E0 and L0 be, respectively, the routine-text, the environ and the locale of R0;
• let E2 be a {newly established} environ, newer in scope than E1, composed of E0 and L0 {E2 is local};
W is the yield, in E2, of the unit of T0.

{Consider the following serial-clause:

PROC samelson = (INT n, PROC (INT) REAL f) REAL:
   BEGIN LONG REAL s :=  LONG 0;
      FOR i TO n DO s +:= LENG f (i) ↑ 2 OD;
      SHORTEN long sqrt (s)
   END;
y := samelson (m, (INT j) REAL: x1[j])

In that context, the last deprocedured-to-real-call has the same effect as the deprocedured-to-real-routine-text in:

y := REAL: (
   INT n = m, PROC (INT) REAL f = (INT j) REAL: x1[j];
   BEGIN LONG REAL s := LONG 0;
      FOR i TO n DO s +:= LENG f (i) ↑ 2 OD;
      SHORTEN long sqrt (s)
   END).

The transmission of the actual-parameters is thus similar to the elaboration of identity-declarations (4.4.2.a); see also establishment (3.2.2.b) and ascription (4.8.2.a).}

{{Minor changes are required at other places in the Report.}}

{{The third bullet of 5.4.2.2 (semantics of formulas) is replaced by}}
• let R1 be {the routine which is} the yield of the parametrization {5.4.3.2.a2} of R with V1, ... , Vn;
W is the yield of the calling {5.4.3.2.b} of R1 in E1;

{{5.4.4.2.Case B, 10.3.4.1.2.c and 10.3.4.9.2 must be modified to show that the routines there created are composed, additionally, from a vacant locale {2.1.1.1.b}.}}



Copyright Notice

The Algol 68 Revised Report contains next statement: 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.

This HTML translation {1.1.5} is a completed, corrected and edited version of an original version by Wilhelm Kloke, that has next copyright statement:
© (2000) Wilhelm Bernhard Kloke, http://vestein.arb-phys.uni-dortmund.de, klokew@acm.org. It may be used for anything otherwise legal, as long as the (above) copyright is not removed and that of the original authors of the report is not violated.

Copyright © 2013 J.M. van der Veer. Updated October 2013.