GlispGlisp
Home
Guide
Playground
  • Overview
  • Syntax
  • Types
  • Evaluation
  • Host API
API
  • English
  • 日本語
GitHub
Home
Guide
Playground
  • Overview
  • Syntax
  • Types
  • Evaluation
  • Host API
API
  • English
  • 日本語
GitHub
  • API

    • glisp
    • build
    • check
    • eval
    • expand
    • expectedType
    • infer
    • lex
    • parse
    • print
    • session
    • types

glisp


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

ParameterType
astAST
envEnv

Returns

AST


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

ParameterType
astAST
envEnv
options?{ maxSteps?: number; }
options.maxSteps?number

Returns

AST


expandLadder()

expandLadder(ast, env, options?): readonly AST[]

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

ParameterType
astAST
envEnv
options?{ maxSteps?: number; }
options.maxSteps?number

Returns

readonly AST[]

Edit this page
Prev
eval
Next
expectedType