The source function only works for function where the .clj where the function is defined is in the classpath. If you have control over all functions, I'd suggest using https://github.com/technomancy/serializable-fn when defining them.
On Wed, Aug 8, 2012 at 11:19 AM, Samuel Lê <samuel...@gmail.com> wrote: > Dear all, > > I am trying to write some code that would take a function name, get its > source code, and create a new function based on the source code. > Unfortunately, the function 'source' from clojure.repl doesn't seem to be > working for the functions I define. > Here is my code: > > (ns test-src.core > (:require [clojure.repl])) > > (defn my-function [x] > (+ x 1)) > > (defn print-src [] > (println (clojure.repl/source my-function))) > > When I try print-src on the repl, I get: > test-src.core> (print-src) > Source not found > nil > nil > > So my question is: how can I access to the source code of the functions I > write? > > Many thanks, > Sam > > -- > 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 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