boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs

commit 8bee01c9d52db4681e63f4f36b3b5ff8517cf023
parent d88863db699e76c741d23345e1e86b759c163436
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Tue, 21 Apr 2026 07:43:45 -0700

lisp tests: step-7 tail-call smoke

Diffstat:
Atests/lisp/07-tailcall.expected | 1+
Atests/lisp/07-tailcall.scm | 32++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/tests/lisp/07-tailcall.expected b/tests/lisp/07-tailcall.expected @@ -0,0 +1 @@ +42 diff --git a/tests/lisp/07-tailcall.scm b/tests/lisp/07-tailcall.scm @@ -0,0 +1,32 @@ +;; Step-7 tail-call smoke test. Exercises every tail-position rewrite +;; in eval/apply: +;; eval_pair → apply application +;; apply → eval body closure body +;; eval_if → eval then/else if-branch tail +;; eval_begin → eval last begin last-form tail +;; eval_sym → lookup symbol resolution +;; eval_lambda → make_closure lambda evaluation +;; eval_quote → car quote evaluation +;; eval_args → cons non-empty arg list +;; +;; Four closures are chained by mutual tail-call (a→b→c→d); d's body +;; combines if + begin + quote + symbol lookup to reach the remaining +;; tail positions in a single go. +;; +;; The LISP.md §"Staged implementation plan" step 7 stress of 10^6 +;; self-calls with flat P1 stack needs an arithmetic primitive to +;; decrement a bounded counter (or a step counter in the interpreter). +;; Both are out of scope for step 7: primitives land at step 10, and +;; the interpreter stays free of per-eval instrumentation. This test +;; therefore covers correctness, not raw depth — the flat-stack claim +;; falls out from the TAIL_Nk op semantics proven in demo.M1. + +(define a (lambda (x) (b x))) +(define b (lambda (x) (c x))) +(define c (lambda (x) (d x))) +(define d (lambda (x) + (if x + (begin (quote ignored) x) + 0))) + +(a 42)