Hi Alan, On 29 Jul 2011, at 10:05, Alan Malloy wrote: >> >> Sorry, I was just trying to simplify things to try and get directly to the >> meat of the problem. > > No apologies needed - reducing to a simple case is great. But here, > the simplification was probably too severe. >
Sorry, I'm English - apologies are just part of normal discourse ;-) > > (defn binding-vec [foos] > ['size `(count ~foos)]) > > (defmacro magic-fn > [& forms] > (let [args (gensym 'args)] > `(fn [& ~args] > (let ~(binding-vec args) > ~@forms)))) > > ((magic-fn (+ size 10)) 1 2) ;=> 12 > Fantastic! I believe this is exactly what I'm looking for. Thank-you so much. Out of interest, are you able to briefly describe (or able to direct me at some relevant literature that does) why your original solution used ~'args and why this version uses (gensym 'args). These subtle macro compile-time/runtime syntax tricks are something I'm clearly yet to master. Sam --- http://sam.aaron.name -- 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