From 85cdb97320de7c2d764af07725ad68a4f00f2dc9 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sun, 7 Jun 2026 17:22:30 -0400 Subject: [PATCH] core: move fn to the syntax tier fn -> fn* is a one-line head-swap (the analyzer treats fn* as the primitive). It's in 00-syntax since the analyzer, kernel, and other overlay macro bodies all use fn. First of the fundamental macros to move. conformance 228x3, fixpoint, clojure-test-suite 3930. --- jolt-core/clojure/core/00-syntax.clj | 4 ++++ src/jolt/core.janet | 11 +---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/jolt-core/clojure/core/00-syntax.clj b/jolt-core/clojure/core/00-syntax.clj index a76a958..101241f 100644 --- a/jolt-core/clojure/core/00-syntax.clj +++ b/jolt-core/clojure/core/00-syntax.clj @@ -60,6 +60,10 @@ ;; pending cells (matching the prior Janet macro). (defmacro declare [& syms] `(do)) +;; fn -> fn*: the analyzer treats fn* as the primitive (it handles params, &-rest, +;; multi-arity); fn is just the public spelling. +(defmacro fn [& args] `(fn* ~@args)) + ;; A fresh jolt symbol inside a macro body (a bare (gensym) returns a Janet symbol ;; the destructurer rejects). This defn compiles fine: by the time a tier triggers ;; the analyzer build the kernel is in place (the build is gated until then). diff --git a/src/jolt/core.janet b/src/jolt/core.janet index c5542af..50522c0 100644 --- a/src/jolt/core.janet +++ b/src/jolt/core.janet @@ -2354,14 +2354,6 @@ # declare macro — accepts symbols, does nothing (forward declaration) -(defn core-fn - "Macro: (fn [args] body) → (fn* [args] body)" - [& args] - (def result @[]) - (array/push result {:jolt/type :symbol :ns nil :name "fn*"}) - (each a args (array/push result a)) - result) - # --- Destructuring expansion (Clojure's `destructure`) ----------------------- # Expands a binding vector containing destructuring patterns into a plain binding # vector (alternating plain-symbol / init-form), using nth/nthnext/get. Shared by @@ -3432,7 +3424,6 @@ "remove-all-methods" core-remove-all-methods "prefer-method" core-prefer-method "Object" core-Object - "fn" core-fn "let" core-let "loop" core-loop "defprotocol" core-defprotocol @@ -3496,7 +3487,7 @@ (defn core-macro-names "Set of core binding names that are macros." [] - @{"when-let" true "defn" true "defn-" true "fn" true "let" true "loop" true "defrecord" true "defprotocol" true "extend-type" true "extend-protocol" true "extend" true "reify" true "proxy" true "definterface" true "lazy-seq" true "lazy-cat" true}) + @{"when-let" true "defn" true "defn-" true "let" true "loop" true "defrecord" true "defprotocol" true "extend-type" true "extend-protocol" true "extend" true "reify" true "proxy" true "definterface" true "lazy-seq" true "lazy-cat" true}) (def init-core! (fn [& args]