Re: Discovering a function's closure

2011-07-10 Thread Oded Badt
I see Guess I'm a bit too much used to programming javascript where a function always carries its source around with it - a very very convenient tool in very functional languages where functions are passed along so often anyway, gr8 thanks! Oded On Jul 7, 12:11 pm, Sunil S Nandihalli wro

Re: Discovering a function's closure

2011-07-07 Thread Sunil S Nandihalli
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 define

Re: Discovering a function's closure

2011-07-07 Thread Oded Badt
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))) Sour

Re: Discovering a function's closure

2011-07-02 Thread Shantanu Kumar
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 wrote: > Hey, > > Does anyone know of a way, given a function, to discove

Discovering a function's closure

2011-07-02 Thread Oded Badt
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 (