Reimplement _with and _for as functions
This commit is contained in:
parent
1e4ad3167b
commit
b81585eaba
@ -43,7 +43,7 @@ be associated in pairs."
|
|||||||
other-kvs))]))))
|
other-kvs))]))))
|
||||||
|
|
||||||
|
|
||||||
(defmacro _with [node args &rest body]
|
(defn _with [node args body]
|
||||||
(if (not (empty? args))
|
(if (not (empty? args))
|
||||||
(do
|
(do
|
||||||
(if (>= (len args) 2)
|
(if (>= (len args) 2)
|
||||||
@ -51,7 +51,7 @@ be associated in pairs."
|
|||||||
(setv p1 (.pop args 0)
|
(setv p1 (.pop args 0)
|
||||||
p2 (.pop args 0)
|
p2 (.pop args 0)
|
||||||
primary [p1 p2])
|
primary [p1 p2])
|
||||||
`(~node [~@primary] (_with ~node ~args ~@body)))
|
`(~node [~@primary] ~(_with node args body)))
|
||||||
`(~node [~@args] ~@body)))
|
`(~node [~@args] ~@body)))
|
||||||
`(do ~@body)))
|
`(do ~@body)))
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ Shorthand for nested with* loops:
|
|||||||
(with* [x foo]
|
(with* [x foo]
|
||||||
(with* [y bar]
|
(with* [y bar]
|
||||||
baz))."
|
baz))."
|
||||||
`(_with with* ~args ~@body))
|
(_with 'with* args body))
|
||||||
|
|
||||||
|
|
||||||
(defmacro with/a [args &rest body]
|
(defmacro with/a [args &rest body]
|
||||||
@ -75,7 +75,7 @@ Shorthand for nested with/a* loops:
|
|||||||
(with/a* [x foo]
|
(with/a* [x foo]
|
||||||
(with/a* [y bar]
|
(with/a* [y bar]
|
||||||
baz))."
|
baz))."
|
||||||
`(_with with/a* ~args ~@body))
|
(_with 'with/a* args body))
|
||||||
|
|
||||||
|
|
||||||
(defmacro cond [&rest branches]
|
(defmacro cond [&rest branches]
|
||||||
@ -108,7 +108,7 @@ used as the result."
|
|||||||
root)))
|
root)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro _for [node args &rest body]
|
(defn _for [node args body]
|
||||||
(setv body (list body))
|
(setv body (list body))
|
||||||
(if (empty? body)
|
(if (empty? body)
|
||||||
(macro-error None "`for' requires a body to evaluate"))
|
(macro-error None "`for' requires a body to evaluate"))
|
||||||
@ -131,7 +131,7 @@ used as the result."
|
|||||||
|
|
||||||
Args may contain multiple pairs, in which case it executes a nested for-loop
|
Args may contain multiple pairs, in which case it executes a nested for-loop
|
||||||
in order of the given pairs."
|
in order of the given pairs."
|
||||||
`(_for for* ~args ~@body))
|
(_for 'for* args body))
|
||||||
|
|
||||||
|
|
||||||
(defmacro for/a [args &rest body]
|
(defmacro for/a [args &rest body]
|
||||||
@ -139,7 +139,7 @@ in order of the given pairs."
|
|||||||
|
|
||||||
Args may contain multiple pairs, in which case it executes a nested for/a-loop
|
Args may contain multiple pairs, in which case it executes a nested for/a-loop
|
||||||
in order of the given pairs."
|
in order of the given pairs."
|
||||||
`(_for for/a* ~args ~@body))
|
(_for 'for/a* args body))
|
||||||
|
|
||||||
|
|
||||||
(defmacro -> [head &rest rest]
|
(defmacro -> [head &rest rest]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user