1、I N T E R N AT IO N A L STANDARD IS0 8485 First edition 1989-1 1-07 Programming languages - APL Langages de programmation - APL National Standard of Canada CA N/CSA -IS0 -8485-96 International Standard IS0 8485 : 1989 has been adopted, without modification, as CAN/CSA-ISO-8485-96, which has been app
2、roved as a National Standard of Canada by the Standards Council of Canada. April 1996 Reference number IS0 8485 : 1989 (E) IS0 8485 : 1989 (E) Foreword IS0 (the International Organization for Standardization) is a worldwide federation of national standards bodies (IS0 member bodies). The work of pre
3、paring International Standards is normally carried out through IS0 technical committees. Each member body interested in a subject for which a technical committee has been established has the right to be represented on that committee. International organizations, govern- mental and non-governmental,
4、in liaison with ISO, also take part in the work. IS0 collaborates closely with the International Electrotechnical Commission (IEC) on all matters of electratechnical standardization. Draft International Standards adopted by the technical committees are circulated to the member bodies for approval be
5、fore their acceptance as International Standards by the IS0 Council. They are approved in accordance with IS0 procedures requiring at least 75 % approval by the member bodies voting. International Standard IS0 8485 was prepared by Technical Committee ISO/TC 97, information processing s ysterns. User
6、s should note that all International Standards undergo revision from time to time and that any reference made herein to any other International Standard implies its latest edition, unless otherwise stated. Annexes A and B are for information only. E IS0 1989 All rights reserved. No part of this publ
7、ication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from the publisher. International Organization for Standardization Case postale 56 0 CH-1211 Genhve 20 0 Switzerland IS0 8485 : I989 (E) CO
8、NTENTS 0 Introduction 3 1 Scope and Field of Application . 5 2 References 7 3 Form of the Standard . . 9 3.1 Form ofDefinitions 9 3.2 Named Arrays in Examples . 10 3.3 Notes . 10 3.4 Cross-References 10 3.5 General Definitions . 11 4 Compliance . 13 4.1 Conforming Implementations 13 4.1.1 Required B
9、ehaviour for Conforming Implementations 13 4.1.2 Required Docurnentation for Conforming Implementations 14 4.1 2.1 Documentation of Optional-Facilities 14 4.t.2.2 Documentation of Impternentation-Defined-facilities 14 4.1.2.3 Consistent Extensions . 14 4.2 Conforming Programs . . 15 4.2.1 Required B
10、ehaviour for Conforming Programs . 15 4.2.2 Required Documentation for Conforming Programs 15 5 Definitions 17 5.t Characters . 17 5.2 Numbers . 19 5.2.1 Elementary Operations . 19 5.2.2 Number Constants 20 5.2.3 Subsets of the Set of Numbers . 21 5.2.4 Implementation Algorithms 23 5.2.5 Defined Ope
11、rations 24 5.3 Objects 26 5.3.1 Lists . 26 27 5.3.2 Arrays 5.3.3 Defined-Functions . 29 5.3.4 Tokens . 30 5.3.4.1 Metaclasses 32 5.3.4.2 Index-List 33 5.3.5 Symbols 33 5.3.6 Contexts 34 5.3.7 Workspaces . 34 5.3.8 Sessions 35 5.3.9 Shared-Variables . 36 5.3.10 Systems . 37 5.4 Evaluation Sequences .
12、 39 5.4.1 Evaluation Sequence Phrases 39 5.4.2 Diagrams . 41 5.5 Otherierms 42 iii IS0 8485 : 1989 (E) . 6 Syntax and Evaluation 43 6.1 Introduction . 43 . . 6.1.1 Evaluate-Line 6.1.2 Character-Diagrams 6.3.3 Evaluate-Statement 6.1.4 Bind-Token-Class 6-1.5 Literal-Conversion . 6.t.6 Statement-Analys
13、is Token-Diagrams 6.2 Reducestatement . 6.3 The Phrase Evaluators 6.3.1 Diagrams . 6.3.2 Remove-Parentheses 6.3.3 Evaluate-Niladic-Function . 6.3.4 Evaiuate-Monadic-Function 6.3.5 Evaluate-Monadic-Operator 6.3.6 Evaluate-Dyadic-Function 6-3.7 Eva I uate-Dyad i c-0 perator 6.3.8 Evaluate-lndexed-Refe
14、rence 6.3.9 Evaluate-Assignment 6.3.10 Evaluate-lndexed-Assignment . 6.3.11 Evaluate-Variable 6.3.12 Build-lndex-List 6.3.13 Process-End-of-Statement . . . . . . . . . . 6.4 The Form Table 7 Scalar Functions . 7.1 Monadic Scalar Functions 7.1.1 Conjugate 7.1.2 Negative . 7.1.3 Signum 7.1.4 Reciproca
15、l 7.1.5 Floor 7.1.6 Ceiling 7.1.7 Exponential . 7.1.8 Natural Logarithm 7.1 . 10Factorial . 7.1.9 Magnitude 7.1.11 Pitimes 7.4.12 Not . 7.2 Dyadic Scalar Functions . . 7.2.1 Plus 7.2.2 Minus 7.2.3 Times . 7.2,4 Divide 7.2.5 Maximum 7.2.6 Minimum . 7.2.7 Power 7.2.8 Logarithm 7.2.9 Residue 7.2.10 Bin
16、omial 7.2.1 1 Circular Functions . . . 7.2.12 7.2.13 7.2.1 4 7.2.1 5 7.2.16 7.2.17 7.2.18 7.2.1 9 7.2.20 7.2.21 And Or . Nand . Nor Equal . Less than Less than or equal to Not equal Greater than or equal to Greaterthan . . 43 45 52 53 54 55 60 63 64 65 65 66 68 69 71 72 73 74 75 76 77 7a 83 84 84 84
17、 85 85 86 86 87 88 88 89 89 90 91 91 92 92 93 93 94 94 95 96 97 99 99 100 100 101 103 103 104 105 a7 1a4 iv APL Standard IS0 8485 : 1989 (E) . 8 Structural Primitive Functions 107 8.t introduction . 107 t 07 108 109 110 110 111 9 Operators a13 113 9-1 Introduction . 8.2 Monadic Structural Primitive
18、Functions 107 8.2.1 Ravel z+, B 8.2.2 Shape . Z+pB . 8.2.3 index Generator Z+iB 8.3.1 Reshape Z+ApB 8.3.2 Join + A , B . 8.3 Dyadic Structural Primitive Functions . . 9.2 Monadic Operators . f14 9.2.1 Reduction 9.2.f Reduction 9.2.1 Reduction 9.2.1 Reduction 9.2.2Scan 9.2.2Scan 9.2.2Scsn 9.2.2Scan 9
19、.3 Dyadic Operators . 9.3.1 Outer Product . 9.3.2 Inner Product IO Mixed Functions . , . , . 10.1 Monadic Mixed Functions 10.1.1 Roll 10.12 Grade Up 10.1.3 Grade Down 10.1.4 Reverse . 10.1.4 Reverse . 10.1.4 Reverse . lU.1.4 Reverse . 10.1.5 Monadic Transpose 10.1.6 Matrix Inverse . 10.1.7 Execute .
20、 10.2 Dyadic Mixed Functions . 113.2.1 Join Along an Axis 10.2.2 Index of . 10.2.3 Member of . 10.2.4 Deal 10.2.5 Compress . 10.2.5 Compress . 10.2.5 Compress . 70.2.5 Compress . 10.2.6Expand 10.2.6 Expand 10.2.6 Expand 10.2.6 Expand 10.2.7 Rotate 10.2.7 Rotate 10.2.7 Rotate 10.2.7 Rotate 102.8 Base
21、 Value 10.2.9 Representation . 10.2.10 Dyadic Transpose 10.2.11 Take . 10.2.12 Drop . 10.2.13 Matrix Divide 10.2.14 Indexed Reference 10.2.15 Indexed Assignment . . Z+f/B 114 114 2 + VCKI B Z+fS B 114 114 Z + ffCK1 B 2 +f B 116 116 Z + fKI B Z r-ft B 1?6 116 Z + ftCK1 B . 117 Z+Ao . fB 117 418 Z + A
22、f . g % . 179 . Z+?B Z+360 by lverson and his colleagues Adin Falkofi, Larry Breed, Dick Lathwell, and Roger Moore in the mid-1960s. Throughout this document - the term “this standard“ is understood to mean “this International Standard“; - subclause“, respectively. the words “chapter“, “section“ and
23、 “subsection“ are understood to mean “clause“, “subclause“ and “sub- 0. Introduction 3 IS0 8485 : 1989 (E) I SCOPE AND FIELD OF APPLICATION This standard defines the programming language APL and the environment in which APL programs are executed. Its purpose is to facilitate interchange and promote
24、portabitity of APL programs and program m i ng ski I Is. This standard specifies the syntax and semantics of APL programs and the characteristics of the environment in which APL programs are executed. It also specifies requirements for conformance to this standard, including the publication of value
25、s and characteristics of implementation properties so that conforming implementations can be meani ngfu I ly compared. This standard does not specify: implementation properties that are likely to vary with the particular equipment or operating system used: required values for implementation limits s
26、uch as APL workspace size or numeric precision; the data structures used to represent APL objects; the facilities available through shared variables. 1. Scope and Field of Application 5 IS0 8485 : 1989 (E) 2 REFERENCES IS0 2375 : 1985, Data processing - Procedure for registration of escape sequences
27、. IS0 2382-15 : 1985, Data processing - Vocabdary - Part 75: Programming languages. 2. References 7 3 FORM OF THE STANDARD This standard is a formal model of an APL machine, specified as a collection of finite sets, diagrams, and evaluation sequences, and objects constructed from finite sets, diagra
28、ms, and evaluation sequences. The finite sets are the implementation-defined character-set. the irnplementation-defined set of numbers, and the enumerated sets array-type, class-names, keyboard-states, mode-names, required-character-set, and workspacepresence. Diagrams are directed graphs used to de
29、signate syntactic forms. Evaluation sequences are formal procedures that operate on finite sets, diagrams, other evaluation sequences and objects defined in the standard. Objects are entities consisting of enumerated set members and other objects. The objects are list, array, definedfunction, token,
30、 symbol, context, workspace, session, shared-variable, and system. Each object has attributes describing its state. The attributes of an array, for example, are its typical element, its shape, and its ravel. Objects often have defined properties derived from their attributes. The rank of an array, f
31、or example, is the shape of the shape of the array. 3.1 FORM OF DEFINITIONS Defined terms in this standard are always set in bold and indexed. The index entry begins with the page number of the definition followed by the page numbers of all references to the term. If the definition and a use of a te
32、rm occur on the same page, that page number will occur twice in the Index. The following terms occur throughout the document and are not cross-indexed: character, content, class, item, and number. Note: Terms in this document include both phrases such as implementation-parameter and words such as ni
33、l. Each definition in this standard takes one of four forms. (1) Regular definitions consist of the term being defined followed by a colon and the body of the definition. The term Boolean is defined in this way. (2) Members of an enumerated set are defined simply by being listed in the definition of
34、 the enumerated set. The term nil is defined in this way, as a member of the enumerated set class-names. (3) Diagrams are defined by directed graphs. The term expression is defined in this way. (4) Definitions of terms that designate evaluation sequences take the following form: The term being defin
35、ed, such as scan. The forms that the evaluation mechanism used in the standard recognises as designating this term, such as 2 + f B. An informal introduction indicating the purpose of the procedure. The informal introduction is considered commentary on the standard. 3. Form ofthe Standard 9 IS0 8485
36、 : 1989 (E) An evaluation sequence expressed in a formal, though English-like, language defined in the subsection Evaluation Sequences. A conforming-implementation is required to emulate the behaviour described in the evaiuation sequence as modified by the additional-requirements, if any. Examples.
37、which show effects of the procedure specified by the evaluation sequence. Examples are considered commentary on the standard. Additional Requirements, giving aspects of the behaviour required of this operation that cannot conveniently be expressed in the evaluation sequence. 3.2 NAMED ARRAYS IN EXAM
38、PLES In the examples in this standard, APL identifiers beginning with N, such as N234 I represent numeric arrays whose shape and content are specified by the digits in the identifier. Each digit in the identifier specifies an element of the shape vector; each element of the array, when broken down i
39、nto digits, gives the index of that element. For example, IVq N23 1234 11 12 13 21 22 23 N234 111 112 113 114 121 122 123 124 131 132 133 134 211 212 213 214 221 222 223 224 231 232 233 234 231 N234C2;3:ll 3.3 NOTES This standard contains notes that comment on the text of the standard. pointing out
40、the significance of definitions, noting relationships between definitions, and otherwise making the text approachable. These notes are set in a different type style than the text of the standard, and are prefixed with the word “Note:“. The following is an example of a note. Note: This is an example
41、Of a Rote. Notes never set requirements for conformance. They may suggest desired properties, but such suggestions are not mandatory for conformance. 3.4 CROSS-REFERENCES The heading levels in this standard are chapter, section, and subsection. When cross-references are given, they are always to a s
42、ubsection title. In the Index, subsections are treated like definitions: the page on which a subsection begins is always the first entry in the Index; subsequent page numbers in the index show where references are made to the subsection. 10 APL Standard IS0 8485 : 1989 (E) 3.5 GENERAL DEFINITIONS Fo
43、r the purpose of this standard, the definitions given in IS0 2382-15 and the following definitions apply: 3.5.1 Program: An application. Note: The term is used in this standard fa indude everything from an APL expression to a collection of workspaces communicating vi2 shared variables. 3.5.2 Impleme
44、ntation: A combination of computer hardware and software that processes (APL) programs. Note: An rmplementation IS an insbnce of tbe object system specrfied by this standard. 3.5.3 Facility (of an implementation): A unit of behaviour. Every facility is one of: Defined-Facility: A facility fully spec
45、ified in this standard and not designated optional or i m p I e m e n tati o n -d ef i ned . Optional-Facility: A facility fully specified in this standard and designated optional. Irrtplementation-Defined-Facility: A facility not fully specified by this standard that is designated implementation-de
46、fined. Consistent-Extension: A facility not specified in this standard that, for a construct this standard specifies as producing an error, gives some effect other than signalling the specified error. 3. Form of the Standard 11 IS0 8485 : 1989 (E) 4 COMPLlANCE 4.1 CON FORM I NG IMPLEMENTATIONS An AP
47、L implementation conforms to this standard if it meets the following requirements for both behaviour and documentation- 4.1 .l Required Sehaviour for Conforming Implementations A conforming-implementation shall provide all definedfacilities and implementation-defined-facilities. Each such facility s
48、hall behave as specified by this standard. A conforming-implementation may provide optional-facilities. If provided, an optional-facility shall behave as specified by this standard. Attempted use of an optional-facility that is not provided shall cause the conforming-implementation to signal an erro
49、r. A conforming-implemenbtion shalt not replace the error signalled by a missing optional-facility with other behaviour. A conforming-implementation may provide consistent-extensions. The presence of a consistent-extension shall not affect the be haviour of a conforming-program. A conforming-implementation shall use algorithms that produce results that are the same as those produced by the evaluation sequences. Mathematical function algorithms shall have at least the accuracy that the algorithms given in the evaluation sequences would produce. Note: The evaluation sequences used rn thi