Function application dispatch for Lisp evaluation.
Handles calling closures, keywords, maps, sets, builtins, and plain functions.
Supported function types
- Keywords as map accessors:
(:key map)→Map.get(map, :key) - Maps as keyword accessors:
(map :key)→Map.get(map, :key) - Sets as membership check:
(set x)→xornil - Closures: user-defined functions
- Builtins:
{:normal, fun},{:variadic, fun, identity}, etc. - Plain Erlang functions
Summary
Functions
Applies a function value to a list of arguments.
Converts Lisp closures to Erlang functions for use with higher-order functions.
Functions
@spec apply_fun(term(), [term()], PtcRunner.Lisp.Eval.Context.t(), (term(), PtcRunner.Lisp.Eval.Context.t() -> {:ok, term(), PtcRunner.Lisp.Eval.Context.t()} | {:error, term()})) :: {:ok, term(), PtcRunner.Lisp.Eval.Context.t()} | {:error, term()}
Applies a function value to a list of arguments.
@spec closure_to_fun(term(), PtcRunner.Lisp.Eval.Context.t(), (term(), PtcRunner.Lisp.Eval.Context.t() -> term())) :: term()
Converts Lisp closures to Erlang functions for use with higher-order functions.
Creates functions with appropriate arity based on number of patterns. Also unwraps builtin function tuples.