A RETURN
statement for a proper procedure has the form:
RETURNThe statement raises the return-exception without an argument. It is allowed only in the body of a proper procedure.
A RETURN
statement for a function procedure has the form:
RETURN Exprwhere
Expr
is an expression assignable to the result type of the
procedure. The statement raises the return-exception with the argument
Expr
. It is allowed only in the body of a function procedure.
Failure to return a value from a function procedure is a checked runtime error.
The effect of raising the return exception is to terminate the current
procedure activation. To be precise, a call on a proper procedure with body
B
is equivalent (after binding the arguments) to:
TRY B EXCEPT return-exception => (*skip*) ENDA call on a function procedure with body
B
is equivalent to:
TRY B; (error: no returned value) EXCEPT return-exception (v) => (the result becomes v) END