Skip to content

Add Rust embedding examples and tidy examples/ - #120

Merged
shsms merged 6 commits into
mainfrom
examples-cleanup
May 14, 2026
Merged

Add Rust embedding examples and tidy examples/#120
shsms merged 6 commits into
mainfrom
examples-cleanup

Conversation

@shsms

@shsms shsms commented May 14, 2026

Copy link
Copy Markdown
Owner

No description provided.

shsms added 6 commits May 13, 2026 23:42
Frees the top-level examples/ directory for Rust embedding examples
that show what the API actually looks like. Drop fib-tail.lisp; the
existing fib.lisp + fib-fast.lisp + tail-recursion.lisp already
cover naive recursive, iterative, and TCO-flavoured demos.
The smallest possible embedding sketch: register a Rust function,
evaluate a Lisp program that calls both it and a built-in, and read
the result back into Rust.
Shows the AsPlist! macro deriving keyword-argument conversion for a
Rust struct (with renamed and optional fields) and a defun that
takes a Plist<T> directly. Three call sites cover the
default / override / partial-override shapes.
Demonstrates the three host-side dispatch helpers — ctx.funcall on a
named symbol, ctx.map over a list with a (lambda ...) value, and
ctx.reduce for an aggregation. Together they cover the common case of
running user-supplied Lisp against host-owned data.
A `Color` struct lives in Lisp as a black-box `TulispAny` value
wrapped by `Shared`. Rust-defined `defun`s construct and inspect it;
Lisp ferries the value through `let` and `list` without peeking
inside. The pattern fits host applications that own complex state
(connections, handles, domain models) and only expose typed
operations to user-supplied Lisp.
Navigational index for the examples directory: a table per category
(Rust embedding vs. Lisp scripts) with one-line descriptions and the
exact cargo invocation. First place a new embedder is likely to look
once they clone the repo.
@shsms
shsms merged commit 82a8dd1 into main May 14, 2026
2 checks passed
@shsms
shsms deleted the examples-cleanup branch May 14, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant