Skip to content

Commit

Permalink
cond-tpl
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 17, 2023
1 parent efa2181 commit e29ba78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/sci/configs/hoplon/hoplon.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
:else (span \"Default\"))
"
[& clauses]
(assert (even? (count clauses)))
(let [[conds tpls] (apply map vector (partition 2 clauses))
syms1 (repeatedly (count conds) gensym)
syms2 (repeatedly (count conds) gensym)]
Expand Down
9 changes: 7 additions & 2 deletions src/sci/configs/macros.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(ns sci.configs.macros
(:refer-clojure :exclude [defmacro]))

(defn add-macro-args [[args body]]
(list (into '[&form &env] args) body))
(def ^:dynamic *debug* false)

(defn add-macro-args [[args & body]]
(list* (into '[&form &env] args) body))

(clojure.core/defmacro defmacro [name & body]
(let [[?doc body] (if (and (string? (first body))
Expand All @@ -12,7 +14,10 @@
bodies (if (vector? (first body))
(list body)
body)]
#_(when *debug* (.println System/err (with-out-str (clojure.pprint/pprint bodies))))
`(defn ~(vary-meta name assoc :sci/macro true)
~@(when ?doc [?doc])
~@(map add-macro-args bodies))))

#_(binding [*debug* true]
(.println System/err (str (macroexpand '(defmacro my-stuff "docstring" [& args] x y z)))))

0 comments on commit e29ba78

Please sign in to comment.