Oded, If you look at the source of source .. you will notice that the source is not stored in the meta information but it just picks up the filename and line-number form the meta info of the function and reads the corresponding files to obtain the source..
This would not be possible if you defined a function at the repl .. this will not possible.. Sunil On Thu, Jul 7, 2011 at 2:16 PM, Oded Badt <[email protected]> wrote: > Thanks, the command you wrote indeed works, but I cant get it to work > for just 'some' function I defined in the repl. > Here's my repl transcript, let me know what I'm doing wrong > > user=> (def f (let [a 5] (fn [x] (+ x a)))) > #'user/f > user=> (f 6) > 11 > user=> (read-string (with-out-str (source f))) > Source > > thanks > Oded > > On Jul 2, 11:20 pm, Shantanu Kumar <[email protected]> wrote: > > To get the source form of the function "map?": > > > > (read-string (with-out-str (source map?))) > > > > This may not work only when the function has been AOT'ed already. Hope > > this helps. > > > > Regards, > > Shantanu > > > > On Jul 2, 11:34 am, Oded Badt <[email protected]> wrote: > > > > > > > > > > > > > > > > > Hey, > > > > > Does anyone know of a way, given a function, to discover it's closure > > > programatically? > > > I often find myself holding a pointer to such a function that only > > > when knowing to what values it is bound to one can tell what it > > > actually does. > > > > > So it can be very helpful to be able to query the runtime (generally > > > in the repl) what the function is bound to > > > > > thanks > > > Oded > > -- > 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 > -- 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
