PtcRunner.Lisp.Runtime.Callable (PtcRunner v0.9.0)

Copy Markdown View Source

Dispatch helper for calling Lisp functions from Collection operations.

This module provides a unified call/2 function that correctly dispatches to all builtin types (normal, variadic, variadic_nonempty, multi_arity, collect) as well as plain Erlang functions.

This solves the problem where closure_to_fun unwrapped variadic builtin tuples into raw 2-arity functions, causing HOFs to fail when calling functions with different arities:

(map + [1 2] [10 20] [100 200])  ;; 3 args - now works
(map + [[1 2] [3 4]])            ;; 1 arg via (apply + pair) - now works
(filter + [0 1 2])               ;; 1 arg - now works
(map range [1 2 3])              ;; multi_arity - now works

Summary

Functions

call(f, args)

@spec call(term(), [term()]) :: term()