PROCEDURE signature signature = "(" { formal-parameter ";" ... } ")" [ ":" result-type ] [ RAISES ( ANY | "{" { exception "," ... } "}" ) ] formal-parameter = [ VAR | READONLY | VALUE ] { "," parameter-name ... } [ ":" parameter-type ] [ ":=" constant-expression ]
If a result-type for the procedure is specified, then the procedure must return a value of that type using a RETURN statement.
If a constant-expression is supplied as a default value for a formal-parameter, the type for the parameter may be omitted. When the procedure is called, if an argument is not supplied for a formal parameter with a default value, the default value is used instead
The RAISES section specifies which exceptions the procedure may 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:
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.
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.
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.
Here we declare a new procedure type Handler which use used by the RegisterHandler routine.
TYPE Handler = PROCEDURE (win: Window.T; time: Time.T): BOOLEAN RAISES ANY; PROCEDURE RegisterHandler (win: Window.T; h: Handler);