Language reference

User-defined functions

Module-level positional functions with local, pass-by-value arguments.

01

Declare and call

A function has zero or one named output. Definitions are registered before script execution, so a call may precede its declaration.

Sun
answer = square(5);

function result = square(value)
    result = value * value;
end
02

Scope and dispatch

  • Calls receive only positional parameters as local variables.
  • Matrix arguments are passed by value.
  • A user function can shadow a built-in.
  • A same-named matrix variable takes precedence and is indexed.
  • Recursion is limited to 32 simultaneous calls.
03

Current limits

Nested functions, closures, anonymous functions, multiple outputs, optional arguments, and automatic function-file lookup are not implemented. Native compilation rejects user functions with interpreter guidance.