up previous next
return    --    exit from a function


Syntax
return
return E

Description
This command is used to exit from a procedure/function. The second form returns the value of the expression E to the user. As a safety measure all returns in a function/procedure must be of the same kind: either they all return a value (function) or none of them returns a value (procedure). return has immediate effect even inside loops; compare with break .

Example
/**/  Define Rev(L) -- reverse a list
/**/    If len(L) < 2 Then Return L; EndIf;
/**/    M := Rev(Tail(L)); -- recursive function call
/**/    append(ref M, L[1]);
/**/    Return M;
/**/  EndDefine;

/**/  Rev([1,2,3,4]);
[4, 3, 2, 1]

See Also