Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nspace

Inspecting namespaces.

nspace.enum

nspace.enum ns -> Tuple

Returns the names of the members of the namespace ns, as a tuple of texts sorted by Unicode code point (so capital letters come first). Names inherited from enclosing scopes are not included. An empty namespace gives Nothing.

nspace.enum {b: 2, a: 1, C: 3} # => ("C", "a", "b")
nspace.enum {}                 # => ()

Combine it with namespace application to list the values:

ns = {x: 1, y: 2}
ns (nspace.enum ns)            # => (1, 2)

nspace.size

nspace.size ns -> Numb

Returns the number of members of the namespace ns. Names inherited from enclosing scopes are not counted.

nspace.size {x: 1, y: 2}       # => 2
nspace.size {}                 # => 0

nspace.parent

nspace.parent ns -> Namespace

Returns the scope in which the namespace ns was created, as a namespace, or Nothing for an outermost scope. This is the scope that ns.name falls back to for names that are not members of ns.

outer = {inner = {}}
nspace.parent outer.inner == outer       # => TRUE