On Fri, May 22, 2009 at 1:37 AM, Konrad Hinsen <konrad.hin...@laposte.net> wrote: > As long as it uses the same variables as the template, it would still > work, but (like the load-and-redefine method) it would fail as soon > as the template author decides to change the names of his variables. > I suppose that to some extent such a risk is inevitable with any > method based on textual replacement. C macros are famous for that > kind of problem, and my templates work at pretty much the same level > as C macros. >
I was thinking that if you have: (def a 2) (def b 3) (defn f [] a) and you set it up with your deftemplate macro where f is the thing that is parameterized, then if you try to pass in a new value for f, like: (fn [] b), it macro expands to (let [f (fn [] b)] (def a 2) (def b 3)) which clearly doesn't work. So you need to pre-declare b, or get b into the namespace with some means other than the template first. And if you did that, it would point at the "old b", which works fine in this case, but might fail for more complex kinds of recursions where eventually the value of b depends on a call to the parameterized function. I see now that my suggestion to include all the defines before the let would also fail badly. I find it ironic that after years of eschewing objects, I'm discovering that at the module level, I desperately want something object-like. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---