PtcRunner.Lisp.Eval.HostContext (PtcRunner v0.14.0)

Copy Markdown View Source

Adapts plain host callbacks to evaluator context and effect semantics.

Host functions cannot thread an Eval.Context through their return value. This module owns the scoped process-local binding that lets runtime helpers recover that context, and the capture brackets used when a host callback may evaluate Lisp. Expression evaluation, callable dispatch, and effect algebra remain owned by their respective evaluator modules.

Summary

Functions

capture_effects(context, do_eval, fun)

@spec capture_effects(PtcRunner.Lisp.Eval.Context.t(), function(), (-> term())) ::
  {:ok, term(), PtcRunner.Lisp.Eval.Effects.t()}
  | {:error, :error | :exit | :throw, term(), Exception.stacktrace(),
     PtcRunner.Lisp.Eval.Effects.t()}

current()

@spec current() :: {PtcRunner.Lisp.Eval.Context.t(), function()} | nil

error!(reason)

@spec error!(term()) :: no_return()

run_outcome(context, do_eval, fun)

@spec run_outcome(PtcRunner.Lisp.Eval.Context.t(), function(), (-> term())) :: term()

run_value(context, do_eval, fun)

with_context(context, do_eval, fun)

@spec with_context(PtcRunner.Lisp.Eval.Context.t(), function(), (-> term())) :: term()

with_materialized_context(context, do_eval, fun)

@spec with_materialized_context(
  PtcRunner.Lisp.Eval.Context.t(),
  function(),
  (PtcRunner.Lisp.Eval.Context.t() -> term())
) :: term()

without_context(fun)

@spec without_context((-> term())) :: term()