core: port when-let to the overlay — finishes the Phase 3 macro migration
Last core macro still in Janet. Goes in 00-syntax (not 30-macros with its if-let/if-some/when-some siblings) because 20-coll's not-empty uses it and 20-coll loads before 30. Via `let` so the binding form may destructure, matching Clojure — the old Janet version used let* and wouldn't. Drops core-when-let + the sym* helper + the intern entry, and empties core-macro-names (no seed binding is a macro anymore).
This commit is contained in:
parent
77e3e3afcf
commit
8bc5bd6f61
3 changed files with 16 additions and 20 deletions
|
|
@ -321,3 +321,12 @@
|
|||
;; (for handles :when/:let/:while and multiple bindings).
|
||||
(defmacro doseq [bindings & body]
|
||||
`(do (count (for ~bindings (do ~@body nil))) nil))
|
||||
|
||||
;; when-let must live in this (early) tier, not 30-macros with its if-let/if-some/
|
||||
;; when-some siblings: 20-coll uses it (not-empty), and 20-coll loads before 30. The
|
||||
;; name binds only in the taken branch (temp# tests the value); via `let` so the
|
||||
;; binding form may itself destructure, matching Clojure.
|
||||
(defmacro when-let [bindings & body]
|
||||
(let [form (bindings 0) tst (bindings 1)]
|
||||
`(let [temp# ~tst]
|
||||
(if temp# (let [~form temp#] ~@body) nil))))
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
`(let [temp# ~tst]
|
||||
(if temp# (let [~form temp#] ~then) ~else))))
|
||||
|
||||
;; when-let lives in 00-syntax (not here): 20-coll uses it, which loads before this tier.
|
||||
|
||||
(defmacro if-some [bindings then & [else]]
|
||||
(let [form (bindings 0) tst (bindings 1)]
|
||||
`(let [temp# ~tst]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue