──────────
Namespaces
──────────
Code that traverses a namespace structure, must make special arrangements to
avoid the unbounded recursion that could occur if a space contained a reference
to one of its ancestors. Function →refs← maintains a list of spaces already
visited and refrains from revisiting any already in the list. Function →tree←
just "gives up" when it encounters a ref that is not an immediate child of the
current space.
Example:
)ns x
#.x
x.ref←x ⍝ cyclic ref
x.ref
#.x
x.⎕nl 9
ref
x.ref.⎕nl 9
ref
x.ref.ref.⎕nl 9
ref
x.ref.ref.ref.ref
#.x
tree x ⍝ →tree← function "gives up" on cyclic refs.
#.x
· ref → #.x
refs x ⍝ →refs← function visits each space exactly once.
#.x
See also: refs tree xrefs
Back to: contents
Back to: Workspaces