Return statement

Example:

  1. return 40+2

The return statement ends the execution of the current procedure. It is only allowed in procedures. If there is an expr, this is syntactic sugar for:

  1. result = expr
  2. return result

return without an expression is a short notation for return result if the proc has a return type. The result variable is always the return value of the procedure. It is automatically declared by the compiler. As all variables, result is initialized to (binary) zero:

  1. proc returnZero(): int =
  2. # implicitly returns 0