← SPL reference

Program structure

SPL programs are sequences of statements; most statements look like method calls or block-opening calls ending with end;.

Statements

Nesting blocks

Inner blocks that end with end; must balance with outer blocks. The parser tracks depth by spotting another ... : block start inside the body.

Functions

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.

Classes (OOP)

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.

Fluency checklist

  1. Know test.* for control flow and comparisons
  2. Use typed print.* and return.*
  3. Pick the right collection: list vs hash vs set vs tuple
  4. Respect scope: locals in blocks/functions vs updating globals
  5. For classes: fields, this, and methods (see OOP guide)
  6. Wrap risky code in error.try / except