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.
This commit is contained in:
Yogthos 2026-06-07 17:22:30 -04:00
parent 023fe637ce
commit 85cdb97320
2 changed files with 5 additions and 10 deletions

View file

@ -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).

View file

@ -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]