☜ | Parameter PassingDraft MDC Standard | ☞ |
Parameter passing is a method of passing information in a controlled manner to and from a subroutine or process as the result of an exfunc, or a Do command with an actuallist, or to a process as the result of a Job command with an actuallist.
actuallist | ::= | ( [ L actual ] ) |
actual | ::= | ┌ │ └ |
. actualname expr |
┐ │ ┘ |
actualname | ::= | │ │ │ |
name @ expratom V actualname |
│ │ │ |
When parameter passing occurs, the formalline designated by the labelref must contain a formallist in which the number of names is greater than or equal to the number of actuals in the actuallist. The correspondence between actual and formallist name is defined such that the first actual in the actuallist corresponds to the first name in the formallist, the second actual corresponds to the second formallist name, et cetera. Similarly, the correspondence between the parameter list entries, as defined below, and the actual or formallist names is also by position in left-to-right order. If the syntax of actual is .actualname, then it is said that the actual is of the call-by-reference format; if the syntax of actual is expr it is said that the actual is of the call-by-value format; otherwise it is said that the actual is of the omitted-parameter format.
When parameter passing occurs, the following steps are executed:
As a result of these steps, two (or more) NAME-TABLE entries may point to the same DATA-CELL. As long as this common linkage is in effect, an Assign, Set, or Kill of an lvn with one of the names appears to perform an implicit Assign, Set, or Kill of an lvn with the other name(s). Note that a Kill does not undo this linkage of multiple names to the same DATA-CELL, although subsequent parameter passing or New commands may.
Execution is then initiated at the first command following the ls of the line specified by the labelref. Execution of the subroutine continues until an eor or a Quit is executed that is not within the scope of a subsequently executed doargument, argumentless Do, xargument, exfunc, exvar, or For. In the case of an exfunc or exvar, the subroutine must be terminated by a Quit with an argument.
At the time of the Quit, the formallist names are unbound and the original saved values, including any undefined states, of the variables named in the formallist are restored. See 8.2.26 for a discussion of the semantics of the Quit operation.
When calling to an externref, call-by-reference has the following additional implementation independent definition:
Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.
Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.
This page most recently updated on 13-Sep-2014, 09:20:37.
For comments, contact Ed de Moel (demoel@jacquardsystems.com)