Skip to content

Commit

Permalink
remove one of the levels of indirection from import-fn, and add defpr…
Browse files Browse the repository at this point in the history
…otocol-once
  • Loading branch information
ztellman committed Apr 22, 2012
1 parent 297d508 commit e6c02e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/potemkin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
(:require
[potemkin.namespace :as namespace]
[potemkin.map :as map]
[potemkin.macros :as macros]))
[potemkin.macros :as macros]
[potemkin.protocols :as protocols]))

(namespace/import-macro namespace/import-macro) ;; totally meta
(import-macro namespace/import-fn)
Expand All @@ -21,6 +22,8 @@
(import-fn macros/transform-defn-bodies)
(import-fn macros/transform-fn-bodies)

(import-fn protocols/defprotocol-once)




2 changes: 1 addition & 1 deletion src/potemkin/namespace.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(when-not vr
(throw (IllegalArgumentException. (str "Don't recognize " sym))))
`(do
(def ~(with-meta n {:protocol protocol}) ~sym)
(def ~(with-meta n {:protocol protocol}) (deref ~vr))
(alter-meta! (var ~n) assoc
:doc ~doc
:arglists ~(list 'quote arglists)
Expand Down
8 changes: 6 additions & 2 deletions src/potemkin/protocols.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

(ns potemkin.protocols)

(defprotocol PotemkinMap
(keys* [this data]))
(defmacro defprotocol-once [name & body]
(if (resolve name)
`(do)
(list* 'defprotocol name body)))

(defprotocol-once PotemkinMap
(keys* [this data]))

0 comments on commit e6c02e0

Please sign in to comment.