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 / session

session

Classes

Session

Defined in: session.ts:42

Constructors

Constructor

new Session(parent): Session

Defined in: session.ts:46

Parameters
ParameterType
parentEnv
Returns

Session

Accessors

env
Get Signature

get env(): Env

Defined in: session.ts:55

Env to evaluate against: the session’s let-frame on top of the prelude.

Returns

Env

Methods

ast()

ast(): LetAST

Defined in: session.ts:60

Snapshot of the session as a let-block AST. Re-parses cleanly.

Returns

LetAST

bindings()

bindings(): readonly string[]

Defined in: session.ts:69

Names currently bound in the session, in insertion order.

Returns

readonly string[]

evalAst()

evalAst(ast): EvalResult

Defined in: session.ts:123

Evaluate an AST against the session env. Top-level (def "name" expr) / (undef "name") are intercepted as binding mutations on the session’s let-block; everything else is delegated to evaluate. Top-level IO results are passed through unchanged so the caller can decide whether to force them (the CLI / browser REPLs auto-run them).

Parameters
ParameterType
astAST
Returns

EvalResult

evalSrc()

evalSrc(src): EvalResult

Defined in: session.ts:137

REPL-friendly entry point. Recognizes top-level name = expr, path/seg = expr (path-based assignment over the existing let-block), and (undef "name"); everything else goes through parse + evalAst. Path segments are identifiers or integer indices separated by /. Throws ParseError if the source can’t be parsed.

Parameters
ParameterType
srcstring
Returns

EvalResult

reset()

reset(): void

Defined in: session.ts:111

Clear every binding. Equivalent to a fresh session.

Returns

void

setAtPath()

setAtPath(path, expr): string | null

Defined in: session.ts:91

Set the AST at a path inside the session let-block. The first segment names a top-level binding; further segments descend into its value’s structure (let-block, record, vector, function body).

Returns null on success, or a string describing why the path could not be reached. The session is mutated only on success.

Parameters
ParameterType
pathreadonly (string | number)[]
exprAST
Returns

string | null

setBinding()

setBinding(name, ast): void

Defined in: session.ts:74

Set or replace a binding. Last-wins by name.

Parameters
ParameterType
namestring
astAST
Returns

void

unsetBinding()

unsetBinding(name): boolean

Defined in: session.ts:79

Remove a binding. Returns whether it was present.

Parameters
ParameterType
namestring
Returns

boolean

References

isIO

Re-exports isIO

Edit this page
Prev
print
Next
types