Download Gauss 11 User Manual

Transcript
Procedures and Keywords
GAUSS procedures are recursive, so the procedure can call itself as long as there is logic in the
procedure to prevent an infinite recursion. The process would otherwise terminate with either an
Insufficient workspace memory message or a Procedure calls too deep message,
depending on the space necessary to store the locals for each separate invocation of the procedure.
Procedures
8.1.4
Returning from the Procedure
The return from the procedure is accomplished with the retp statement:
retp;
retp(expression1,expression2,. . .,expressionN);
The retp statement can have multiple arguments. The number of items returned must coincide
with the number of rets in the proc statement.
If the procedure was defined with no items returned, the retp statement is optional. The endp
statement that ends the procedure will generate an implicit retp with no objects returned. If the
procedure returns one or more objects, there must be an explicit retp statement.
There can be multiple retp statements in a procedure, and they can be anywhere inside the body
of the procedure.
8.1.5
End of Procedure Definition
The endp statement marks the end of the procedure definition:
endp;
An implicit retp statement that returns nothing is always generated here so it is impossible to run
off the end of a procedure without returning. If the procedure was defined to return one or more
objects, executing this implicit return will result in a Wrong number of returns error message
and the program will terminate.
8-5