← SPL reference

Arrow notation (<-)

SPL uses a single two-character token <- (less-than and hyphen) for assignment sugar and for an alternate function-definition header. It is not the same as writing < and - as two operators.

Assignment

name <- expr; means the same as name.setVar(expr); — including scoping rules (update an existing binding or create one in the innermost frame). The semicolon is optional, like other statements.

n <- 3;
n.setVar(math.multiply(n, 2));

Function alias (<- code:)

After zero or more parameter names (space-separated identifiers), you may write <- code: to open a function body. This is equivalent to functionDefine.name(param1, param2, ...): for the same name and parameters. The identifier code is reserved in this position — it must appear immediately after <- and before :.

addOne x <- code: return.number(math.add(x, 1));

noop <- code: return.number(0);

twice x <- code:
    return.number(math.multiply(x, 2));
end;

The block after : follows the same rules as any ... : block — including optional one-line bodies when the first statement sits on the same line as the colon.

Choosing a style