Return Statements

A Return statement performs two role. First it will terminate the execution of a routine. Secondly, in the case of a Function the statement will return the value of the function.

Within a Shape ( including Program ) the form of the statement is :-

returnstmt ::= Return ;

Within a Function the form of the statement is :-

returnstmt ::= Return expression ;

The expression is any expression that yields a value with a type that matches the declared return type of the function.

Function Number Squared(Number x)
    Begin
	Return x * x;
    End;