Go to the first, previous, next, last section, table of contents.

Procedure Types

PROCEDURE <sig>
  where
<sig> = "(" { <formal> ";" ... } ")" 
           [ ":" <result type> ]
           [ RAISES ( ANY | "{" { <exception> "," ... } "}" ) ] 
 
<formal> = [ VAR | READONLY | VALUE ] <id> { "," <id> ... } 
           [ ":" <type> ] [ ":=" <const expr> ]

If a result type for the procedure is specified, then the procedure must return a value of that type.

If a constant expression <const expr> is supplied as a default value for a formal parameter, the type may be omitted, and when the procedure is called, if an argument is not supplied for a formal with a default value, the default value is used to initialize the formal.

The RAISES section specifies which exceptions the procedure is allowed to raise. Any exceptions that occur in the procedure, possibly as the result of a call to another procedure, that are not handled by the procedure and that do not appear in the RAISES clause cause a checked run-time error. If the RAISES section is omitted, then any exceptions raised cause a checked run-time error.

The VAR, VALUE, and READONLY parameter modes determine how the actual argument is associated with the formal parameter:

@bullet{VALUE}
This is the default mode, and means "call by value." The formal parameter contains a copy of the value of the actual argument. Changes to the formal parameter do not affect the actual argument.
@bullet{VAR}
This means "call by reference." The formal parameter is linked to the actual argument. Changes to the formal parameter are reflected in the actual argument. In general, the actual argument must be a variable. No default value may be specified.
@bullet{READONLY}
This means generally "call by reference," but the procedure may not modify the formal parameter. This provides the protection of call by value with the efficiency of call by reference, and should be used when large arrays or records need to be passed as parameters but should not be changed.


Go to the first, previous, next, last section, table of contents.