← SPL reference

Arrow & question mark notation

This page covers the <- token (assignment and <- code: functions) and the ?(cond) <- run: sugar for test.ifTrue only.

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.

Question mark (?(cond) <- run:)

A concise form for only test.ifTrue (not ifFalse / elseIf / else). The keyword run must appear after <- and before :. It desugars to test.ifTrue(cond): with the same body.

?(test.isLess(1, 2)) <- run: print.string("1 is less than 2");

Equivalent long form:

test.ifTrue(test.isLess(1, 2)):
    print.string("1 is less than 2");
end;

Same one-line vs multi-line rules apply: if the first statement starts on the same line as :, you may omit end; for that block.

Choosing a style