Merge pull request #1345 from Kodiologist/cond-in-core-macro-def
Don't use `cond` in the definition of a core macro
This commit is contained in:
commit
3dcf91ab39
@ -86,16 +86,14 @@
|
|||||||
(setv belse (if (and (isinstance lst HyExpression) (= (get lst 0) "else"))
|
(setv belse (if (and (isinstance lst HyExpression) (= (get lst 0) "else"))
|
||||||
[(body.pop)]
|
[(body.pop)]
|
||||||
[]))
|
[]))
|
||||||
(cond
|
(if
|
||||||
[(odd? (len args))
|
(odd? (len args)) (macro-error args "`for' requires an even number of args.")
|
||||||
(macro-error args "`for' requires an even number of args.")]
|
(empty? body) (macro-error None "`for' requires a body to evaluate")
|
||||||
[(empty? body)
|
(empty? args) `(do ~@body ~@belse)
|
||||||
(macro-error None "`for' requires a body to evaluate")]
|
(= (len args) 2) `(for* [~@args] (do ~@body) ~@belse)
|
||||||
[(empty? args) `(do ~@body ~@belse)]
|
(do
|
||||||
[(= (len args) 2) `(for* [~@args] (do ~@body) ~@belse)]
|
(setv alist (cut args 0 None 2))
|
||||||
[True
|
`(for* [(, ~@alist) (genexpr (, ~@alist) [~@args])] (do ~@body) ~@belse))))
|
||||||
(setv alist (cut args 0 None 2))
|
|
||||||
`(for* [(, ~@alist) (genexpr (, ~@alist) [~@args])] (do ~@body) ~@belse)]))
|
|
||||||
|
|
||||||
|
|
||||||
(defmacro -> [head &rest rest]
|
(defmacro -> [head &rest rest]
|
||||||
|
Loading…
Reference in New Issue
Block a user