ISO/IEC 11756:1999
(Main)Information technology — Programming languages — M
Information technology — Programming languages — M
This International Standard describes the M programming language.
Technologies de l'information — Langages de programmation — M
General Information
Relations
Standards Content (Sample)
INTERNATIONAL
ISOAEC
STANDARD
11756
Second edition
1999-06-01
Information technology - Programming
languages - M
Technologies de I’informa tion - Langages de programmation - M
Reference number
ISO/I EC 11756: 1999(E)
---------------------- Page: 1 ----------------------
lSO/lEC 11756:1999(E)
Contents
1. Scope . 1
2.Normativereferences .
1
3.Conformance .
2
3.1 Implementations
............................................ 2
3.2Programs. .
2
4.Definitions .
4
5. Metalanguage description
............................................. 7
6Routineroutine .
9
6.1 Routine head routinehead
9
.....................................
6.2 Routine body routinebody
.................................... IO
6.2.1 Level line levelline
........................................ IO
6.2.2 Formal line formalline
..................................... IO
6.2.3Labellabel .
IO
6.2.4 Label separator Is
11
.........................................
6.25 Line body linebodv
11
............................................
6.3 Routine execution
.......................................... II
6.3.1 Transaction processing
.................................... 12
6.3.2 Error processing
.......................................... 13
6.4 Embedded programs 14
.......................................
7.Expressionexpr.
15
..................................................
7.1 Expression atom expratom
................................... 15
7.1 .I Variables
................................................ 15
7.1.2 Variable name glvn
16
...........................................
7.1.2.1 Local variable name Ivn
16
..................................
7.1.2.2 Local variable handling.
.................................. 16
7.1.2.3 Process-stack
19
..........................................
7.1.2.4 Global variable name ovn
20
....................................
7.1.3 Structured system variable ssvn
............................. 21
7.1.3.1 *$CHARACTER
........................................ 21
7.1.3.2 *$DEVICE 23
.............................................
7.1.3.3 “$GLOBAL
............................................. 23
7.1.3.4”$JOB . 24
7.1.3.5*$LOCK
............................................... 24
7.1.3.6 *$ROUTINE
24
............................................
7.1.3.7*$SYSTEM
............................................. 25
7.1.3.8 *$Z[unspecified]
......................................... 25
7.1.3.9 ssvns specifying default environments
....................... 25
7.1.4 Expression item expritem
................................... 26
7.1.4.1 String literal strlit
........................................ 26
0 ISO/IEC 1999
All rights reserved. Unless otherwise specified, no part of this publication 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.
ISO/IEC Copyright Office l Case Postale 56 l CH-1211 Geneve 20 l Switzerland
Printed in Switzerland
---------------------- Page: 2 ----------------------
0 ISO/IEC lSO/lEC 11756:1999(E)
7.1.4.2 Numeric literal numlit . 27
7.1.4.3Numericdatavalues . 27
7.1.4.4 Meaning of numlit .
28
7.1.4.5 Numeric interpretation of data . 28
7.1.4.6 Integer interpretation . 29
7.1.4.7 Truth-value interpretation . 29
7.1.4.8 Extrinsic function exfunc . 29
7.1.4.9 Extrinsic special variable exvar
............................. 30
7.1.4.10 Intrinsic special variable names svn .
30
7.1.4.11 Unaryoperatorunatvop . r.
34
..........................
7.1.4.12Namevaluenamevalue . 35
7.1.5 Intrinsic function function . 35
7.1.5.1 $ASCII . 36
7.1.5.2 $CHAR
................................................ 37
7.1.5.3$DATA .
37
7.1.5.4 $EXTRACT . 37
7.1.5.5$FlND. . 38
7.1.5.6 $FNUMBER . 38
7.1.5.7$GET .
39
7.1.5.8 $JUSTlFY .
40
7.1.5.9 $LENGTH . 40
7.1.5.lO$NAME . 40
7.1.5.11 $ORDER
............................................. 41
7.1.5.12 $PIECE . 42
7.1.5.13$QLENGTH . 43
7.1.5.14 $QSUBSCRlPT . 44
7.1.5.15 $QUERY . 44
7.1.5.16 $RANDOM . 45
7.1.5.17 $REVERSE . 45
7.1.5.18 $SELECT . 45
7.1.5.19 $STACK . 45
7.1.5.20 $TEXT . 47
7.1.5.21 $TRANSLATE . 47
7.1.5.22$VIEW . 48
7.1.5.23$Z. . 48
7.2 Expression tail exprtail 48
..........................................
7.2.1 Binary operator binarvop .
48
7.2.1.1 Concatenation operator . 49
7.2.1.2 Arithmetic binary operators . 49
7.2.2 Truth operator truthop 49
......................................
7.2.2.1 Relational operator relation . 49
7.2.2.2 Numeric relations
....................................... 50
7.2.2.3 String relations . 50
7.2.2.4 Logical operator logicalop . 50
7.2.3 Pattern match pattern 51
........................................
8.Commands . 52
8.1 General command rules . 52
8.1.1 Spaces in commands .
53
8.1.2 Comment comment
....................................... 54
8.1.3 Command argument indirectio n .
54
8.1.4 Post conditional postcond . 54
8.1.5 Command timeout timeout . 55
8.1.6 Line reference lineref . 55
8.1.6.1 Entry reference entrvref 55
....................................
8.1.6.2 Label reference labelref .
56
8.1.6.3 External reference externref . 57
. . .
III
---------------------- Page: 3 ----------------------
0 ISOAEC
lSO/lEC 11756:1999(E)
8.1.7 Parameter passing
........................................
57
8.2 Command definitions
........................................
59
8.2.1 BREAK
.................................................
59
8.2.2CLOSE
.................................................
59
8.2.3DO .
60
8.2.4ELSE .
61
8.2.5FOR .
61
8.2.6GOTO .
63
8.2.7HALT mmmmmm==m=m====m=====mmmrnmm~~m~~~~mm~~~~~m~~~mmmm~~
63
8.2.8HANG
..................................................
63
8.2.9IF .
64
8.2.10JOB .
64
8.2.11KlLL. .
65
8.2.12LOCK .
66
8.2.13MERGE. .
67
8.2.14NEW
..................................................
68
8.2.15 OPEN
................................................. 69
8.2.16QUl-T .
70
8.2.17 READ
.................................................
71
8.2.18SET
...................................................
73
8.2.19 TCOMMIT
..............................................
75
8.2.20 TRESTART
............................................. 76
8.2.21 TROLLBACK
...........................................
76
8.2.22 TSTART
...............................................
76
8.2.23USE.
.................................................
77
8.2.24VIEW .
78
8.2.25WRITE .
78
8.2.26 XECUTE
...............................................
79
8.2.27Z
.....................................................
80
9. Character Set Profile charset
.........................................
80
lO.Characterset
.....................................................
81
11. Expression elements
............................................... 81
ll.lNames .
81
11.2 External routines and names
81
1 1 .3 Loca I va r i a b I es
. . . . . . . . . .
................................................................
81
11.3.1 Number of local variables
................................. 81
11.3.2 Number of subscripts
..................................... 81
11.3.3 Values of subscripts
...................................... 82
11.4 Global variables
...........................................
82
11.4.1 Number of global variables
................................
82
11.4.2 Number of subscripts
.....................................
82
11.4.3 Values of subscripts
......................................
82
11.4.4 Numberof nodes
........................................
82
11.5Datatypes .
82
11.6 Number range
............................................
83
11.7lntegers .
83
11.8 Character strings
..........................................
83
11.9 Special variables
..........................................
83
12.Expressions .
83
12.1 Nesting of expressions
..................................... 83
12.2Results .
83
12.3 External references
......................................
. . 84
---------------------- Page: 4 ----------------------
0 ISO/IEC
lSO/lEC 11756:1999(E)
13 Routines and command lines .
84
13.1 Command lines .
84
13.2 Number of command lines
..................................
84
13.3 Number of commands
..................................... 84
13.4Labels .
84
13.5 Number of labels
.......................................... 84
13.6 Number of routines .
84
14 External routine calls
............................................... 85
15 Character Set Profiles
.............................................. 85
16lndirection .
85
17 Storage space restrictions
........................................... 85
18Process-stack .
86
19Formats .
86
19.1 mnemonicspace
.......................................... 86
19.2 controlmnemonic
.......................................... 86
19.3 Parameters .
87
20Transactionprocessing .
87
20.1 Number of modifications in a TRANSACT10 N
87
20.2 Number of nested TSTARTs within a TRANSACTi~ N 1: 1: .
..:I 1: 1: 87
21 Other portability requirements
........................................ 87
22Thebinding. .
88
22.1 Control-functions with an effect on $X or $Y or both
88
22.2 Control-functions with an effect on $KEY
... .. ..... . . . .. . . . . . . .. . .. 89
22.3 Control-functions with an effect on $DEVICE
................... 89
22.4 Open-ended definitions .
90
23Portabilityissues . 91
23.1 Implementation
........................................... 91
23.2 Application
............................................... 91
24Conformance .
92
AnnexA .
93
AnnexB .
96
AnnexC .
97
AnnexD .
99
AnnexE .
101
AnnexF .
103
AnnexG .
105
AnnexH .
106
Index .
109
V
---------------------- Page: 5 ----------------------
ISOllEC I 1756: 1999(E) 0 ISO/IEC
Foreword
IS0 (the International Organization for Standardization) and IEC (the International
Electrotechnical Commission) form the specialized system for worldwide
standardization. National bodies that are members of IS0 or IEC participate in the
development of International Standards through technical committees established
by the respective organization to deal with particular fields of technical activity. IS0
and IEC technical committees collaborate in fields of mutual interest. Other
international organizations, governmental and non-governmental, in liaison with IS0
and IEC, also take part in the work.
In the field of information technology, IS0 and IEC have established a joint
technical committee, ISO/IEC JTC I. Draft International Standards adopted by the
joint technical committee are circulated to national bodies for voting. Publication as
an International Standard requires approval by at least 75% of the national bodies
casting a vote.
International Standard ISO/IEC 11756 was prepared by Joint Technical Committee
ISO/IEC JTC 1, Morrnation technology, Subcommittee 22, Programming languages,
their environments and system software interfaces.
This second edition cancels and replaces the first edition SO/IEC 11756: 1992),
which has been technically revised.
Annex A forms an integral part of this International Standard
Annexes B to H are
for information only.
---------------------- Page: 6 ----------------------
0 ISOllEC
lSO/IEC 11756:1999(E)
lntrodu ction
Section I consists of nine clauses that describe the MUMPS language. Clause 1
describes the metalanguage used in the remainder of Section 1 for the static syntax.
The remaining clauses describe the static syntax and overall semantics of the language.
The distinction between “static” and “dynamic” syntax is as follows. The static syntax
describes the sequence of characters in a routine as it appears on a tape in routine
interchange or on a listing. The dynamic syntax describes the sequence of characters
that would be encountered by an interpreter during execution of the routine. (There is
no requirement that MUMPS actually be interpreted). The dynamic syntax takes into
account transfers of control and values produced by indirection.
Clauses IO through 21 highlight, for the benefit of implementors and application
programmers, aspects of the language that must be accorded special attention if M
program transferability (i.e., portability of source code between various M implementa-
tions) is to be achieved. It provides a specification of limits that must be observed by
both implementors and programmers if portability is not to be ruled out. To this end,
implementors must meet or exceed these limits, treating them as a minimum
requirement. Any implementor who provides definitions in currently undefined areas
must take into account that this action risks jeopardizing the upward compatibility of the
implementation, upon subsequent revision of the M Language Specification. Application
programmers striving to develop portable programs must take into account the danger of
employing “unilateral extensions” to the language made available by the implementor.
The following definitions apply to the use of the terms explicit limit and implicit limit within
this document. An explicit limit is one which applies directly to a referenced language
construct. Implicit limits on language constructs are second-order effects resulting from
explicit limits on other language constructs. For example, the explicit command line
length restriction places an implicit limit on the length of any construct which must be
expressed entirely within a single command line.
Clauses 22 through 24 describe the binding between M and ANSI X3.64. ANSI X3.64 is
a functional standard for additional control functions for data interchange with two-
dimensional character-imaging input and/or output devices. It is an ANSI standard, but
also an IS0 standard with roughly similar characteristics exists (IS0 2022). As such, it
has been implemented in many devices worldwide. It is expected that M can be easily
adapted to these implementations.
The standard defined as ANSI X3.64 defines a format for device-control. No physical
device is required to be able to perform all possible control-functions. In reality, as some
functions rely on certain physical properties of specific devices, no device will be able to
perform all functions. The standard, however, does not specify which functions a device
should be able to do, but if it is able to perform a function, how the control-information
for this function is to be specified.
This binding is to the functional definitions included in X3.64. The actual dialogue
between the M implementation and the device is left to the implementor.
vii
---------------------- Page: 7 ----------------------
This page intentionally left blank
---------------------- Page: 8 ----------------------
INTERNATIONAL STANDARD-O ISO/IEC
ISOllEC 11756:1999(E)
Information technology- Programming languages - M
1. Scope
This International Standard describes the M programming language.
2. Normative references
The following standards contain provisions which, through reference in this text, constitute
provisions of this International Standard. At the time of publication, the editions indicated were
valid. All standards are subject to revision, and parties to agreements based on this
International Standard are encouraged to investigate the possibility of applying the most recent
editions of the standards indicated below. Members of IEC and IS0 maintain registers of the
currently valid International Standards.
ISOllEC 9075: 1992, Information technology -- Database languages -- SQL
ANSI X3.4-l 990, (ASCII Character Set)
ANSI X3.64-l 979, RI990 (ANSI Terminal Device Control Mnemonics)
---------------------- Page: 9 ----------------------
0 ISO/IEC
ISODEC 11756:1999(E)
3. Conformance
3.1 Implementations
A conforming implementation shall
a) correctly execute all programs conforming to both the International Standard and the
implementation defined features of the implementation
b) reject all code that contains errors, where such error detection is required by the
International Standard
ch provides a definition of all implementation-defined
c) be accompanied by a document whi
the form:
features and a conformance statement of
“xxx version v conforms to Xl 1 .I-yyyy with the following exceptions:
. . .
Supported Character Set Profiles are . . .
Uniqueness of the values of $SYSTEM is guaranteed by . .‘I
where the exceptions are those components of the implementation which violate this
International Standard or for which minimum values are given that are less than those defined in
Section 2.
An MDC conforming implementation shall be a conforming implementation except that the
conforming document shall be this International Standard together with any such current MDC
documents that the vendor chooses to implement. The conformance statement shall be of the
form:
“xxx version v conforms to Xl 1 .I-yyyy, as modified by the following MDC documents:
ddd (MDC status m)
with the following exceptions:
. . .
Supported Character Set Profiles are . . .
Uniqueness of the values of $SYSTEM is guaranteed by . .”
An MDC strictly conforming implementation is an MDC conforming implementation whose MDC
modification documents only have MDC Type A status and which has no exceptions.
A . . . implementation is an implementation conforming to one of the above
options in which the requirements of Section 2 are replaced by the
requirements and other extensions required by the are implemented.
implementation may claim more than
An one level of conform ante if it provides a switch
bY
wh ich the user is able to select the confo lrmance level.
3.2 Programs
A strictly conforming program shall use only the constructs specified in Section 1 of this
International Standard, shall not exceed the limits and restrictions specified in Section 2 of the
International Standard and shall not depend on extensions of an implementation or
implementation-dependent features.
2
---------------------- Page: 10 ----------------------
ISOIIEC 11756:1999(E)
0 ISO/IEC
A strictly conforming non-AX// program is a strictly conforming program, except that the
restrictions to the ASCII character set in Section 2 are removed.
A strictly conforming program is a strictly conforming program, except that the
restrictions in Section 2 are replaced by those specified by the and any
extensions specified by the may be used.
A conforming program is one that is acceptable to a conforming implementation.
---------------------- Page: 11 ----------------------
0 ISO/IEC
ISO/IEC 11756:1999(E)
4. Definitions
For the purposes of this International Standard, the following definitions apply.
4.12 concatenation: The act or result of
4.1 argument (of a command): M command
joining two strings together to make one
words are verbs. Their arguments are the
string.
objects on which they act.
4.13 conditional expression: Guards a
4.2 array: M arrays, unlike those of most other
command (sometimes an argument of a
computer languages, are trees of unlimited
command). Only if the expression’s value is
depth and breadth. Every node may
true does the command execute (on the
optionally contain a value and may also have
argument). See truthvalue.
zero or more descendant nodes. The name of
4.14 contains: a logical operator that tests
a subscripted variable refers to the root, and
the nth subscript refers to a node on the nth whether one string is a substring of another.
4.15 data-cell: in the formal model of M
level. Arrays vary in size as their nodes are
set and killed. See scalar, subscript. execution. It contains the value and
4.3 atom: A singular, most-basic element of a subscripts (if any) of a variable, but not the
name of the variable. Many variable names
construction. For example, some atoms in an
may point to a data-cell due to parameters
expression are names of variables and
functions, numbers, and string literals. passed by reference. See also name-table,
value-table.
4.4 block: One or more lines of code within a
4.16 descriptor: uniquely defines an element.
routine that execute in line as a unit. The
It comprises various characteristics of the
argumentless DO command introduces a
element that distinguish the element from all
block, and each of its lines begins with one or
more periods. Blocks may be nested. See other similar elements.
4.17 device-dependent: That which depends
level.
4.5 call by reference: A calling program on the device in question.
4.18 empty: an entity that contains nothing.
passes a reference to its actual parameter. If
the called subroutine or function changes its For example, an empty string contains no
formal parameter, the change affects the characters; it exists but has zero length. See
actual parameter as well. Limited to also null string, NULL character.
unsubscripted names of local variables, either 4.19 environment: a set of distinct names. For
scalar or array. See also call by value.
example, in one global environment all global
4.6 call by value: A calling program passes
variables have distinct names. Similar to a
the value of its actual parameter to a directory in many operating systems.
subroutine or function. Limited to a single
4.20 evaluate: to derive a value.
value, that is, the value of a scalar variable or
4.21 execute: to perform the operations
of one node in an array. See also call by
specified by the commands of the language.
reference.
4.22 extract: to retrieve part of a value,
4.7 call: A procedural process of transferring
typically contiguous characters from a string.
execution control to a callee by a caller.
4.23 extrinsic: a function or variable defined
4.8 callee: The recipient of a call.
and created by M code, distinct from the
4.9 caller: The originator of a call.
primitive functions or special variables of the
4.10 command: A command word (a verb), an language. See intrinsic.
optional conditional expression, and zero or 4.24 follow: to come after according to some
more arguments. Commands initiate all ordering sequence. See also sorts after.
actions in M. 4.25 function: a value-producing subroutine
4.11 computationally equivalent: The result of
whose value is determined by its arguments.
a procedure is the same as if the code
Intrinsic functions are defined elements of the
provided were executed by a M program
language, while extrinsic functions are
without error. However, there is no implication
programmed in M.
that executing the code provided is the
4.26 global variable: a scalar or array variable
method by which the result is achieved.
that is public, available to more than one job,
4
---------------------- Page: 12 ----------------------
0 ISOAEC lSO/IEC 11756:1999(E)
string may contain any number of
and persistent, outliving the job. See local
occurrences of this character (up to the
variable.
4.27 graphic: a visible character (as opposed maximum string length). A string consisting
of one NULL character has a length of 1
to most control characters).
(one).
4.28 hidden: unseen. The NEW command
4.44 null string: 1. A string consisting of 1
hides local variables. Also pertains to unseen
(one) NULL character; 2. A string consisting
elements invoked to define the operation of
of 0 (zero) characters.
some commands and functions.
4.45 object: An entity considered as a whole
4.29 intrinsic: a primitive function or variable
in relation to other entities.
defined by the language standard as opposed
4.46 own: To have exclusive access to a
to one defined by M code. See extrinsic.
resource. In M this pertains to devices.
4.30 job: A single operating system process
4.47 parameter: A qualifier of a command
running a M program.
modifies its behavior (for example by
4.31 label: Identifies a line of code.
imposing a time out), or augments its
4.32 level: The depth of nesting of a block of
argument (for example by setting
code lines. The first line of a routine is at level
characteristics of a device). Some parameters
1 and successively nested blocks are at
are expressions, and some have the form
levels 2, 3, . . . Formally, the level of a line is
keyword=value. See argument.
one plus Ii. Visually, Ii periods follow the label
4.48 parameter (of a function or subroutine):
(if any) and precede the body of the line. See
The calling program provides actual
block.
parameters. In the called function or
4.33 local variable: A scalar or array variable
subroutine, formal parameters relate by
that is private to one job, not available to
position to the caller’s actual arguments. See
other jobs, and disappears when the job
also call by reference, call by value,
terminates. See global variable.
parameter passing.
4.34 lock: To claim or obtain exclusive access
4.49 parameter passing: This alliterative
to a resource.
phrase refers to the association of actual
4.35 mapping: The logical association or
parameters with formal parameters when
substitution of one element for another.
calling a subroutine or function.
4.36 map: The act of mapping.
4.50 partition: The random access memory in
4.37 metalanguage: Underlined terms used in
which a job runs.
the formal description of the M language.
4.51 piece: A part of a string, a sub-string
4.38 modulo: An arithmetic operator that
delimited by chosen characters.
produces the remainder after division of one
4.52 pointer: Indirection allows one M varia
...
Questions, Comments and Discussion
Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.