Add Rust embedding examples and tidy examples/ - #120
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.