Matchbox 0.2

Scope

Scope determines where a declared name can be used.

Matchbox 0.2 has top-level and function-local scopes:

Scope Description
Top level Variables and functions declared outside a function.
Function Parameters, variables, and nested functions declared in a function.

A function can read and assign top-level variables. A local declaration with the same name shadows the top-level declaration inside that function.

Names cannot be redeclared in the same scope. Matchbox resolves declarations in source order, so a variable or function must be declared before it is used.

Nested functions do not capture variables from an enclosing function. They can use their own local names and top-level names.