glisp / expand
expand
Functions
expand()
expand(
ast,env):AST
Defined in: expand.ts:92
One step of macro expansion. If ast is a call to a Glisp closure with a body, substitute the closure’s parameters with the call’s argument ASTs throughout the body and return the resulting AST. Otherwise return ast unchanged.
Reserved special forms (?, |>, def, undef, overload) are not expanded: expanding them would lose their custom dispatch semantics. For repeated expansion until a fixed point, see expandLadder and expandAll.
Parameters
| Parameter | Type |
|---|---|
ast | AST |
env | Env |
Returns
expandAll()
expandAll(
ast,env,options?):AST
Defined in: expand.ts:72
Convenience: same as expandLadder(ast, env).at(-1) — only the fully-expanded fixed point.
Parameters
| Parameter | Type |
|---|---|
ast | AST |
env | Env |
options? | { maxSteps?: number; } |
options.maxSteps? | number |
Returns
expandLadder()
expandLadder(
ast,env,options?): readonlyAST[]
Defined in: expand.ts:51
Iterate expand from ast until a fixed point is reached. Returns the sequence of intermediate ASTs (the “abstraction ladder” per docs/spec/eval.md), starting with the input. The last entry is always the fixed point — calling expand again yields the same node.
maxSteps guards against pathologically slow but non-cyclic expansion. Defaults to 64.
Parameters
| Parameter | Type |
|---|---|
ast | AST |
env | Env |
options? | { maxSteps?: number; } |
options.maxSteps? | number |
Returns
readonly AST[]