procedure (Z.100)

Procedures are defined by means of procedure definitions. The procedure is invoked by means of a procedure call identifying the procedure definition. Parameters are associated with a procedure call. Which variables are affected by the interpretation of a procedure is controlled by the parameter passing mechanism. Procedure calls may be actions or part of expressions (value returning procedures only).

Concrete graphical grammar

<procedure diagram> ::=
<frame symbol> contains {<procedure heading>
{ { <procedure text area>
| <procedure area>
| <macro diagram> }*
<procedure graph area> }set }

<procedure area> ::=
< graphical procedure reference >
| <procedure diagram>

<procedure text area> ::=
<text symbol> contains
{ < variable definition >
| <data definition>
| <select definition>
| <macro definition> }*

<procedure heading> ::=
<procedure preamble>

procedure {<procedure name>| <procedure identifier> }
[<formal context parameters>]
[<virtuality constraint>]
[< specialisation >]
[<procedure formal parameters>]
[<procedure result>]

<procedure graph area> ::=
[< procedure start area >]
{<state area> | <in-connector area> }*

<procedure preamble> ::=
[< virtuality >][exported [ as <remote procedure identifier> ]]

<procedure formal parameters> ::=
fpar <formal variable parameters>
{, <formal variable parameters> }*

<formal variable parameters> ::=
<parameter kind> <parameters of sort>

<parameter kind> ::= [ in/out | in ]

<procedure result> ::= returns [<variable name>] <sort>

An exported procedure cannot have formal context parameters and its enclosing scope must be a process type, process definition, service type or service definition.

< variable definition > in a <procedure definition>, cannot contain revealed, exported, revealed exported, exported revealed <variable name>s.

The exported attribute is inherited by any subtype of a procedure. A virtual exported procedure must contain exported in all redefinitions. The optional as-clause in a redefinition must denote the same <remote procedure identifier> as in the supertype. If omitted in a redefinition, the <remote procedure identifier> of the supertype is implied.

Two exported procedures in a process, including possible services, cannot mention the same <remote procedure identifier>.

Semantics

exported in a <procedure preamble> implies that the procedure may be called as a remote procedure.

A procedure is a means of giving a name to an assembly of items and representing this assembly by a single reference. The rules for procedures impose a discipline upon the way in which the assembly of items is chosen, and limit the scope of the name of variables defined in the procedure.

A procedure variable is a local variable within the procedure that can neither be revealed nor viewed, nor exported, nor imported. It is created when the procedure start node is interpreted, and it ceases to exist when the return of the procedure graph is interpreted.

The interpretation of a <procedure call> causes the creation of a procedure instance and the interpretation to commence in the following way:

a) A local variable is created for each in parameter, having the name and sort of the in parameter. The variable gets the value of the expression given by the corresponding actual parameter if present. Otherwise the variable gets no value, i.e. it becomes "undefined".

b) A formal parameter with no explicit attribute has an implicit in attribute.

c) A local variable is created for each <variable definition> in the Procedure-definition

d) Each in/out parameter denotes a variable which is given in the actual parameter expression. The contained Variable-name is used throughout the interpretation of the procedure graph when referring to the value of the variable or when assigning a new value to the variable.

e) The Transition contained in the < procedure start area > is interpreted.

The nodes of the procedure graph are interpreted in the same manner as the equivalent nodes of a process or service graph, i.e. the procedure has the same complete valid input signal set as the enclosing process, and the same input port as the instance of the enclosing process that has called it, either directly or indirectly.

Model

Specifying <procedure result> results in <procedure formal parameters> with an extra formal variable parameter appended having the in/out attribute, a distinct new name (unless specified explicitly in <procedure result>) as <variable name>, and the <sort> of <procedure result> as <sort>.

When a <procedure body> or <procedure graph area> contains <return> or <return area> with an <expression>, the procedure must have at least one formal parameter with <parameter kind> in/out or a <procedure result>.

Any occurrence of <return> or <return area> with an <expression> inside the <procedure body> or <procedure graph area> is replaced by a <task> containing an assignment of the contained <expression> to the rightmost in/out variable, followed by a <return> or <return area> without any <expression>.

A <procedure start area> which contains < virtuality > is called a virtual procedure start area.