On Thu, Mar 29, 2012 at 11:35 AM, Shantanu Kumar <kumar.shant...@gmail.com> wrote: > > > On Mar 29, 5:50 pm, Cedric Greevey <cgree...@gmail.com> wrote: >> On Wed, Mar 28, 2012 at 11:48 PM, Shantanu Kumar >> >> <kumar.shant...@gmail.com> wrote: >> >> If you control the third line of: >> >> >> (defn foo [x y] >> >> (let [z (bar y (next x))] >> >> (println "Done in " (find-name) ".") >> >> (* 4 z (count x)))) >> >> >> then don't you control the first? >> >> > Cedric – Unfortunately, no. The target is pre-written code that may >> > have been created using (1) clojure.core/defn or (2) several `defxyz` >> > kind of macros already. Injecting a macro that internally uses `find- >> > name` is something I can do, hence this need. >> >> If you can replace some other macro that code's source uses, surely >> you can also replace defn? You'd need to inject the clojure.core/defn >> wrapper into the other function's namespace, but you'd have to do that >> with the other macro anyway. > > Cedric – I meant "inject" as in into the body, not to alter/wrap the > macro itself that defines the function. So, effectively I alter/wrap > neither of `defn` and `defxyz` macros.
You're not making sense. There are two cases. Either you can directly edit the source code for the function, in which case you can substitute a modified defn; Or you cannot, but you can cause it to compile with a substituted version of one of the functions, macros, etc. that it references, in which case you can cause it to compile with a substituted version of the defn macro. What you're suggesting would only make sense if you have a source file with a function like this: 81 (defn foo [...] 82 (let [x (compute-something ...)] 83 (do-something x ...) 84 (calculate-whatever ...))) and you're able to edit lines 82, 83, and 84 but not line 81 (or whatever). But I can't see any plausible circumstance where that would be the case. -- 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