Hi, Am 28.05.2009 um 21:10 schrieb CuppoJava:
I find defblockfn very useful for functions that take a single function as one of the parameters. Macros are much harder and more error-prone to write than functions, so almost all of my macros do nothing but wrap a body in a function.
Yes. This is very good style for macro writing. Most macros need to control only a tiny bit of the evaluation. The rest can be safely packed into a function which receives a thunk. This has many advantages as I detailed in another mail of this thread. I'm not sure your macro is too simple, though. I will have to have look at the use cases I have for it. Whether it is powerful enough.
One technique, which was helpful was to just call the defblockfn macro and then expand the call to freshly defined macro. (defblockfn foo [a b c] ...) (macroexpand-1 '(foo :a :b :c))Could you explain a bit more what you mean by that? I don't quite understand what you're saying, but it sounds potentially very useful.
When you expand the defblockfn macro you get the "garbage" you described for the inner macro. I just made outer macro useable. Then I simply called it and expanded the resulting inner macro. The you a nice expansion. As I showed in the example. First simply use the defblockfn macro to define the foo macro. And then simply macroexpand a call to it, to see whether it expands to the right thing. It basically just one level of indirection. Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature