core: move ->/->>/declare to the syntax tier
Threading macros (recursive; the expand-once cache makes that free) and declare (a no-op on Jolt — forward refs resolve via pending cells). They live in 00-syntax because the analyzer itself uses -> and declare; validated by conformance 228x3 (the bootstrap-compiled analyzer expands them). conformance 228/228 x3, clojure-test-suite 3930.
This commit is contained in:
parent
613aaa5451
commit
d0d48f0ebd
2 changed files with 25 additions and 30 deletions
|
|
@ -35,3 +35,27 @@
|
|||
(if (empty? clauses)
|
||||
nil
|
||||
`(if ~(first clauses) ~(nth clauses 1) (cond ~@(drop 2 clauses)))))
|
||||
|
||||
;; Threading: a list form threads x in as the first (->) or last (->>) arg; a bare
|
||||
;; symbol becomes (form x). Recursive; the expand-once cache makes that free.
|
||||
(defmacro -> [x & forms]
|
||||
(if (empty? forms)
|
||||
x
|
||||
(let [form (first forms)
|
||||
threaded (if (seq? form)
|
||||
`(~(first form) ~x ~@(rest form))
|
||||
`(~form ~x))]
|
||||
`(-> ~threaded ~@(rest forms)))))
|
||||
|
||||
(defmacro ->> [x & forms]
|
||||
(if (empty? forms)
|
||||
x
|
||||
(let [form (first forms)
|
||||
threaded (if (seq? form)
|
||||
`(~(first form) ~@(rest form) ~x)
|
||||
`(~form ~x))]
|
||||
`(->> ~threaded ~@(rest forms)))))
|
||||
|
||||
;; Forward declaration is a no-op on Jolt — the compiler resolves forward refs via
|
||||
;; pending cells (matching the prior Janet macro).
|
||||
(defmacro declare [& syms] `(do))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue