user=> (meta odd?)
{:ns #<Namespace clojure.core>, :name odd?, :file "clojure/core.clj", :line 1093, :arglists ([n]), :added "1.0", :doc "Returns true if n is odd, throws an exception if n is not an integer"}
In 1.3, this metadata is missing:
user=> (meta odd?)
nil
The previous behavior was useful. I made use of it. Is it a bug that it's gone away? If not, what's the reasoning behind the change?
-----
Brian Marick, Artisanal Labrador
Now working at http://path11.com
Contract programming in Ruby and Clojure
Occasional consulting on Agile
user=> (meta #'clojure.core/odd?)
{:ns #<Namespace clojure.core>, :name odd?, :arglists ([n]), :added
"1.0", :static true, :doc "Returns true if n is odd, throws an
exception if n is not an integer", :line 1323, :file
"clojure/core.clj"}
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
I understand that. Useful code is sometimes given a function object to work with, not a Var.
Ah, I get your point now...
What about:
(meta (var odd?))
(meta (resolve 'odd?))
> I suppose you could iterate over all known Vars and construct a map from fns to the Vars that contain them. Then, given a fn, you can look up the Var and get its metadata. It would break if anyone redefines or binds the Var, of course.
How about putting the information back on the function? Who would be harmed by reverting back to old behavior?
>
> On Oct 11, 2011, at 7:48 PM, Stuart Sierra wrote:
>
>> I suppose you could iterate over all known Vars and construct a map from fns to the Vars that contain them. Then, given a fn, you can look up the Var and get its metadata. It would break if anyone redefines or binds the Var, of course.
>
> How about putting the information back on the function? Who would be harmed by reverting back to old behavior?
Much of the information in var metadata is just not applicable to the function — and, in the presence of binding and with-redefs, you want to be sure to keep function and var metadata distinct. IIRC, the application of function/var metadata changed when functions became eligible for "updating" via with-meta.
That said, it seems like there are some bits of var metadata that should migrate to the underlying function. Probably worth filing a bug for it.
- Chas
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en