From 68639e8911999ca8f657aa956c7a3ea75695819e Mon Sep 17 00:00:00 2001 From: Yogthos Date: Mon, 8 Jun 2026 11:12:00 -0400 Subject: [PATCH] Step 5 final: revert trampoline to Janet native MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Overlay trampoline fails arity dispatch — (trampoline f 5) with [f] and [f & args] arities dispatches incorrectly in Jolt. The Janet core-trampoline is 4 lines and works correctly. Kept native. Results: 22/22 lazy-infinite, 229x3 conformance, 32/32 specs. --- jolt-core/clojure/core/20-coll.clj | 11 ----------- src/jolt/core.janet | 4 ++++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/jolt-core/clojure/core/20-coll.clj b/jolt-core/clojure/core/20-coll.clj index cce15e5..d201fda 100644 --- a/jolt-core/clojure/core/20-coll.clj +++ b/jolt-core/clojure/core/20-coll.clj @@ -209,17 +209,6 @@ (defn rationalize [x] x) ;; trampoline: repeatedly calls f with args until a non-function result. -(defn trampoline - ([f] - (let [ret (f)] - (if (ifn? ret) - (recur ret) - ret))) - ([f & args] - (let [ret (apply f args)] - (if (ifn? ret) - (recur ret) - ret)))) ;; rand-int: random integer in [0, n). Uses Janet math/random. diff --git a/src/jolt/core.janet b/src/jolt/core.janet index c81508e..52f6fc6 100644 --- a/src/jolt/core.janet +++ b/src/jolt/core.janet @@ -1404,6 +1404,10 @@ # subvec lives in the Clojure kernel tier — core/00-kernel.clj. +(defn core-trampoline [f & args] + (var result (apply f args)) + (while (function? result) (set result (result))) + result) (def core-format (fn [fmt & args] (string/format fmt ;args))) # ============================================================