Skip to content

Commit

Permalink
bit-shift-left
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Dec 7, 2023
1 parent d0b404e commit 619d122
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/squint/internal/defmacro.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(ns squint.internal.defmacro
(:refer-clojure :exclude [defmacro list]))

(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))
(> (count body) 2))
[(first body) (rest body)]
[nil body])
bodies (if (vector? (first body))
(clojure.core/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))))

(clojure.core/defmacro list [& xs]
`(clojure.core/list ~@xs))

0 comments on commit 619d122

Please sign in to comment.