explicit return from a procedure - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Procedures and Functions : return

return - explicit return from a procedure

Calling Sequence

return expr1, expr2, ...


expr[1], ...


expression sequence (possibly null)



One common form of return from a procedure invocation occurs when execution ``falls through'' the end of the statement sequence which makes up the procedure body, in which case the value of the procedure invocation is the value of the last statement executed.


A return statement causes an immediate return to the point where the current procedure was invoked.


If return is via the return statement then the value of the procedure invocation is the expression sequence specified in the return statement.


A return statement may only appear within a procedure or module definition.


A return statement that appears within a module definition body stops the execution of the module definition during the instantiation of modules to which it evaluates. The expression sequence following the return statement must be NULL.


A particular form of return is the ``fail return'', in which it is desired to return the unevaluated function invocation as the result of a computation.  This can be done by using the construct return 'procname(args)'.  Here, procname and args are special names which are substituted by, respectively, the name of the current procedure, and the sequence of actual arguments with which the procedure was called.


The special name FAIL is commonly used by Maple library procedures as a return value which indicates that the computation failed or was abandoned, in cases where returning the unevaluated function invocation is not appropriate.


In the Standard Worksheet interface, a return statement can appear at the top level (not inside a procedure body or module definition).  This is used to "return" a value from a worksheet which was invoked from another worksheet via the DocumentTools[RunWorksheet] command.


The return statement supersedes the RETURN function, which still exists for backward compatibility. However, use of the RETURN procedure is strongly discouraged.

See Also

error, FAIL, module, procedure, procname, Standard Worksheet, using_parameters

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam