lumbda/examples
russell@unturf.com 06b93c588a portal over HTTP: 9/9 cross-runtime, plus eval-to-global-env fix
Closes the last loop promised in the whitepaper's Future Work: a
node serves its state as an S-expression portal over HTTP, another
node pulls it down with tcp-connect + tcp-recv and materializes the
bindings locally via (eval (read-from-string line)).

examples/portal-http-server.lsp (90 lines):
- Holds some state (counter, my-int, my-list, my-fib, my-str)
- GET /portal → S-expression body: a sequence of (define ...) forms
- GET / → HTML index
- Uses heap-snapshot / heap-restore for O(1) memory on asm

examples/portal-http-client.lsp (90 lines):
- tcp-connect, send HTTP/1.0 GET, receive full response
- Strip headers (walk to first \r\n\r\n)
- Split body by \n, eval each non-empty, non-comment line
- The remote bindings are now live locally

3×3 server/client matrix: all 9 combinations green. Every runtime
hosts, every runtime consumes. The wire format is Scheme source;
no schema, no JSON, no Protobuf.

Prerequisite fix: `eval` semantics aligned across all three impls.

Python and C's `eval` special form previously evaluated its result
in the CALLER's env, so a nested (eval (read-from-string
"(define x 42)")) would install x in the local function scope —
invisible to later top-level code. asm's bi_eval always used the
global env (r14). With this commit, all three impls evaluate the
eval'd result in the global env, matching asm's existing behavior.

Python: uncommonlisp.py leval eval-handler now does `env = env.g`
before continuing the trampoline.
C: c/eval.c SYM_EVAL branch now does `env = env->global`.
asm: no change (already correct).

One pre-existing Python defect surfaced by the client:
`count` is a SRFI-1-style builtin (`d(S('count'), ...)`), so a
local let-loop variable named `count` collides with it in the
inline-cache lookup path and OP_LOOK_ADD1 fires on the builtin
instead of the local. Worked around by renaming the loop
accumulator to `cnt`. Underlying Env.lookup shortcut-to-global
issue is out of scope for this commit.

Regression: 975 tests still green.
2026-04-17 13:41:48 -04:00
..
fibonacci.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
generator.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
http-client-bench.lsp heap-snapshot + native HTTP client + MOAD-0001 cleanup 2026-04-16 20:49:32 -04:00
http-server.lsp heap-snapshot + native HTTP client + MOAD-0001 cleanup 2026-04-16 20:49:32 -04:00
mergesort.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
objects.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
portal-http-client.lsp portal over HTTP: 9/9 cross-runtime, plus eval-to-global-env fix 2026-04-17 13:41:48 -04:00
portal-http-server.lsp portal over HTTP: 9/9 cross-runtime, plus eval-to-global-env fix 2026-04-17 13:41:48 -04:00
portal-prime.lsp Add portal: serialize and resume VM state across machines 2026-04-13 19:00:11 -04:00
repl-server.lsp S-expressions over sockets — RPC + remote REPL in portable Scheme 2026-04-17 09:00:04 -04:00
rpc-chain-bench.lsp rpc-chain-bench: Python → C relay → asm, timing end-to-end 2026-04-17 09:18:42 -04:00
rpc-client.lsp S-expressions over sockets — RPC + remote REPL in portable Scheme 2026-04-17 09:00:04 -04:00
rpc-relay.lsp rpc-chain-bench: Python → C relay → asm, timing end-to-end 2026-04-17 09:18:42 -04:00
rpc-server.lsp S-expressions over sockets — RPC + remote REPL in portable Scheme 2026-04-17 09:00:04 -04:00