Returning simple typed values from functions

Simple data types such as INTEGER, DECIMAL, VARCHAR are returned by value with the RETURN instruction.

When returning a simple typed value, the runtime system pushes a copy of the data on the stack. The STRING data type is an exception to this rule: elements of this type are return by mutable reference: the whole string value is not copied on the stack, only the reference to the string value is copied.

MAIN
  DEFINE x INTEGER
  LET x = int_add(10,20)
END MAIN

FUNCTION int_add(n1,n2)
  DEFINE n1, n2 INTEGER
  RETURN (n1+n2)
END FUNCTION