On Feb 24, 2009, at 11:59 AM, Stuart Halloway wrote:

Is there a way to programmatically retrieve the :tag of an argument?
The var metadata will return the tag of a return value...

Yes. Here an example:

user=> (source slurp)
(defn slurp
  "Reads the file named by f into a string and returns it."
  [#^String f]
(with-open [r (new java.io.BufferedReader (new java.io.FileReader f))]
    (let [sb (new StringBuilder)]
      (loop [c (. r (read))]
        (if (neg? c)
          (str sb)
          (do
            (. sb (append (char c)))
            (recur (. r (read)))))))))
nil
user=> ^#'slurp
{:ns #<Namespace clojure.core>, :name slurp, :file "core.clj", :line 2949, :arglists ([f]), :doc "Reads the file named by f into a string and returns it."}
user=> (meta (first (first (:arglists ^#'slurp))))
{:tag String}
user=>

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to