I realized, actually, after your post Ken, that my implementation of macroexpand-all does not do exactly what I want.
The properties of macroexpand-all, should be: (eval some-expression) is *always* equal to (eval (macroexpand-all some-expression)) This is not the case in my current implementation because, as you said, names can be shadowed by local bindings. I'll have to write a more involved version... Your macroexpand-all has the same problem but you're probably not using it the same way I am. Thanks for your reply -Patrick On Feb 10, 11:20 pm, Ken Wesson <kwess...@gmail.com> wrote: > On Thu, Feb 10, 2011 at 11:10 PM, CuppoJava <patrickli_2...@hotmail.com> > wrote: > > Your solution with map-ps is quite elegant. > > Thanks. My implementation of macrolet also uses it. In fact, I wrote > my macroexpand-all as a tool to aid in developing that. It was useful > both for debugging macrolet itself and for testing which "special > forms" are really macros, and what the true special forms are, so I > could identify all of the possible local-name-binding forms post > macroexpansion. (This turns out, apparently, to be: > > (let* [name x name x name x] b) > > (loop* [name x name x name x] b) > > (fn * ([name name name] b) ([name name] b) ...) > > (fn * name ([name] b) ...) > > (try > b > (catch Exception name b) > (finally b)) > > where "name" appears in the positions where local names may be bound. > I needed to know all of this because macrolet had to actually > implement its own macro-expansion engine, which in turn needs to > detect when the names of local macros, and macrolet itself, have been > shadowed.) > > > I was actually a little annoyed that I had to deal with different data > > structures when walking through Clojure code, as opposed to > > Lisp/Scheme code. > > Fortunately that's something you can abstract over. > > > The doall was necessary for my use-case actually. Some of the macros I > > write interact with the environment (ie. they're not side-effect > > free). > > Ah. Usually it's best for macros to *expand* sometimes into code with > side-effects but avoid *having* side effects directly. I find the > latter an unusual case in my own experience. > > > So I had to ensure that macroexpand-all actually *does* run all > > the macros appropriately. > > I see. -- 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