SPL programs are sequences of statements; most statements look like
method calls or block-opening calls ending with end;.
use a.b.c; — load a modulename.setVar(expr); — assignobj.method(args); — expression statementobj.method(args): then
nested statements, closed by end;
inherit path.spl; (only inside
classDefine) — see
Classes & OOP
Inner blocks that end with end; must
balance with outer blocks. The parser tracks depth by spotting another
... : block start inside the body.
Define with functionDefine.name(a,b):
… end;. Call with
function.name(expr, expr); or
function.call(function.ref(name), ...).
Return with return.number /
return.string /
return.boolean.
Optional parameters use
default.NAME.setVar(value) in the parameter list
(after any required names). Inside the body, use
NAME as a normal parameter. Omitted trailing
arguments are filled at the call by evaluating
value (earlier parameters are in scope, so a
default may refer to them).
functionDefine.add(n, default.k.setVar(2)): return.number(math.add(n, k)); end; print.number(function.add(3)); print.number(function.add(3, 10));
Define with classDefine.ClassName():,
optional constructorDefine():,
methodDefine.meth(a):, and
inherit lib.file.spl;. Instantiate with
class.createObj(varName, ClassName);.
Full syntax and calling rules:
Classes & OOP.
test.* for control flow and comparisonsprint.* and return.*this, and methods (see OOP guide)error.try / except