core: move if-let/if-some/when-some/while/dotimes macros to overlay
Phase 3 batch 2 (jolt-1j0), 5 user-facing macros as defmacro + syntax-quote. The conditional-binding macros use the auto-gensym temp# idiom so the name binds only in the taken branch (the else/empty branch sees the outer scope, carrying forward the earlier scope fix). when-let stays in Janet for now — 20-coll uses it, so it must remain available before the macro tier loads. Note: gensym in a macro body resolves to Janet's 0-arity builtin, so explicit (gensym "prefix") fails — use template auto-gensym (foo#) instead. conformance 228/228 x3, full suite green (incl. the if-let scope regression spec, now exercising the overlay macro), clojure-test-suite 3930, bench A/B flat.
This commit is contained in:
parent
330a3a23d9
commit
e611034550
3 changed files with 38 additions and 68 deletions
|
|
@ -34,4 +34,13 @@
|
|||
["if-not no else" "nil" "(if-not true :then)"]
|
||||
["if-not no else hit" ":then" "(if-not false :then)"]
|
||||
["comment -> nil" "nil" "(comment a b c)"]
|
||||
["comment in do" "42" "(do (comment ignored) 42)"])
|
||||
["comment in do" "42" "(do (comment ignored) 42)"]
|
||||
["if-let then" "6" "(if-let [x 5] (inc x) :none)"]
|
||||
["if-let else" ":none" "(if-let [x nil] (inc x) :none)"]
|
||||
["if-let else scope" "9" "(let [x 9] (if-let [x nil] :t x))"]
|
||||
["if-some zero" "1" "(if-some [x 0] (inc x) :none)"]
|
||||
["if-some nil" ":none" "(if-some [x nil] x :none)"]
|
||||
["when-some multi" "14" "(when-some [x 7] (inc x) (* x 2))"]
|
||||
["when-some nil" "nil" "(when-some [x nil] x)"]
|
||||
["while loop" "3" "(let [a (atom 0)] (while (< @a 3) (swap! a inc)) @a)"]
|
||||
["dotimes sum" "10" "(let [a (atom 0)] (dotimes [i 5] (swap! a + i)) @a)"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue