> If you want to be able to query a function for its source code later > on, that's tougher. You'll need to make a macro that wraps defn and > assigns a copy of the body form to a metadata tag on the function's > name.
I'm resurrecting this thread because I'm actually hitting this problem myself! (To clarify: I have no problem handling the source code myself... I just need somewhere to put it.) Unfortunately, I don't think I can use this workaround, because I need to serialize *anonymous* functions — there's no var to which I can attach metadata, and I don't know of a way to create a non-global var to stuff into my data structures. I'm leery of interning tons of global vars, because this application will be up and running for months at a time. At this point I can see three workarounds for my case: * Define a structure of some kind that is essentially a metadata wrapper around a function, or * Maintain some external map from function object to its original source code, or * Drop down to Java and implement a class that's just like Fn (probably wrapping one) but also implements IMeta. I don't really like any of those. Any further thoughts from anyone? Is there any particular reason why Fn doesn't implement IMeta? Thanks, -R --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---