On Wed, Jul 13, 2011 at 9:35 PM, Tim Robinson <[email protected]> wrote:
> I know I can get the meta data using the following form:
>
> => (meta #'get)
> {:ns #<Namespace clojure.core>, :name get, :file "clojure/
> core.clj"....
>
> Is there a means to get the meta data from the stored function without
> using its identifier?
>
> ie. knowing this result:
>
> => get
> #<core$get clojure.core$get@77036a6b>
>
> Can I somehow do this:
>
> =>(meta #<core$get clojure.core$get@77036a6b>)
> java.lang.Exception: Unreadable form...
=> (let [a get] (meta a))
{:ns #<Namespace clojure.core>, :name get, :file "clojure/core.clj",
:line 1154, :arglists ([map key] [map key not-found]), :added "1.0",
:inline-arities #{2 3}, :inline #<core$get__inliner
clojure.core$get__inliner@97e3a5>, :doc "Returns the value mapped to
key, not-found or nil if key not present."}
Current versions, at least, put the meta on the function object itself
and not just the Var. (This was with 1.2). So if you have the
function, in a local like a above, you can get at the metadata.
With just the class name? You can create an instance and call the function:
=> (let [a (.newInstance clojure.core$get)] (a {:x 42} :x))
42
But the new instance won't have any metadata:
=> (let [a (.newInstance clojure.core$get)] (meta a))
nil
--
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en