Skip to content

Commit

Permalink
import-fn -> import-macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ztellman committed Apr 22, 2012
1 parent f2e2628 commit 8649792
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/potemkin.clj
Expand Up @@ -22,7 +22,7 @@
(import-fn macros/transform-defn-bodies)
(import-fn macros/transform-fn-bodies)

(import-fn protocols/defprotocol-once)
(import-macro protocols/defprotocol-once)



Expand Down
4 changes: 4 additions & 0 deletions src/potemkin/namespace.clj
Expand Up @@ -22,6 +22,8 @@
protocol (:protocol m)]
(when-not vr
(throw (IllegalArgumentException. (str "Don't recognize " sym))))
(when (:macro m)
(throw (IllegalArgumentException. (str "Calling import-fn on a macro: " sym))))
`(do
(def ~(with-meta n {:protocol protocol}) (deref ~vr))
(alter-meta! (var ~n) assoc
Expand All @@ -43,6 +45,8 @@
doc (:doc m)]
(when-not vr
(throw (IllegalArgumentException. (str "Don't recognize " sym))))
(when-not (:macro m)
(throw (IllegalArgumentException. (str "Calling import-macro on a non-macro: " sym))))
`(do
(def ~n ~(resolve sym))
(alter-meta! (var ~n) assoc
Expand Down
4 changes: 3 additions & 1 deletion src/potemkin/protocols.clj
Expand Up @@ -8,7 +8,9 @@

(ns potemkin.protocols)

(defmacro defprotocol-once [name & body]
(defmacro defprotocol-once
"defonce for defprotocol"
[name & body]
(if (resolve name)
`(do)
(list* 'defprotocol name body)))
Expand Down

0 comments on commit 8649792

Please sign in to comment.