Hello,

I tried adding :doc and :added metadata on a protocol method signature but 
found it hard to do:

;; defn-like, docstring then metadata map -> nope
(defprotocol P (foo "mydoc" {:added "1.0"} [_]))
; => CompilerException java.lang.IllegalArgumentException: Parameter 
declaration missing, compiling:(/tmp/form-init3901889500037802283.clj:1:1)

;; defn-like, docstring in the metadata map -> nope

(defprotocol P (foo {:doc "mydoc" :added "1.0"} [_]))

; => CompilerException java.lang.IllegalArgumentException: Parameter 
declaration missing, compiling:(/tmp/form-init3901889500037802283.clj:1:1)

;; Maybe after the arguments? -> ok for the doc
(defprotocol P (foo [_] "mydoc"))
(select-keys (meta #'foo) [:doc :added])
; => {:doc "mydoc"}

;; Let's add the :added bit -> nope
(defprotocol P (foo [_] "mydoc" {:added "1.0"}))
(select-keys (meta #'foo) [:doc :added])
; => {:doc "mydoc"}

;; Maybe both in the same map? -> nope
(defprotocol P (foo [_] {:doc "mydoc" :added "1.0"}))
(select-keys (meta #'foo) [:doc :added])
; => {:doc {:doc "mydoc" :added "1.0"}}

;; Not really. ^{} -style? -> nope
(defprotocol P (^{:doc "mydoc" :added "1.0"} foo [_]))
(select-keys (meta #'foo) [:doc :added])
; => {:doc nil :added "1.0"}

;; ^{} + after the args -> yeah!
(defprotocol P (^{:added "1.0"} foo [_] "mydoc"))
(select-keys (meta #'foo) [:doc :added])
; => {:doc "mydoc" :added "1.0"}


Is there a reason for this? I’m quite surprised using ^{:doc "..."} doesn’t 
work.

Thanks,

-- Baptiste Fontaine

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to