← SPL reference

Scoping

The interpreter uses a chain of scopes: global (module) plus pushed frames for functions and blocks.

Lookup: identifiers resolve from innermost frame outward to global.

Assignment (x.setVar(v)): if x exists in any frame, that binding is updated (including globals from inside a function—how shared module state works). Otherwise x is created in the innermost frame.

Namespaces like math.add are not variables; they live on the interpreter’s library table, not the scope chain.

Where new frames appear

Full detail: someProgrammingLanguage/SCOPING.md in the repo.