I read Jorge Tavares’s article on Macro Patterns a few days ago. I was thinking about replying to mention a few of my favorites:
with- pattern which makes sure a special variable is bound for the body and makes sure the tied resources are released at the end of the block.
- Macros which collect content (usually into a special variable) so they can do something with the content at the end of the close of the macro.
Then, I was working on something tonight when I re-discovered a favorite pattern that I’d forgotten about: Putting multiple wrappers on the same body.
I have now made a macro called
define-web-file which takes a CL-Who or Parenscript body and wraps it up as both a Hunchentoot handler and a
write-to-file wrapper. Now, I can test interactively with Hunchentoot and generate the whole web application when I’m ready.
The July meeting of the Twin Cities Lisp Users Group was this past Tuesday. There were four presentations on the agenda:
The presentation slides and videos of the talks are available through the links above, and directly at the tclispers.org site. Enjoy!
I have a pretty good grasp on macros in Lisp, C/C++, TeX, m4, and nroff. Lisp macros are, far and away, the most powerful in that set. In fact, Lisp macros get a bad rap by sharing a name with macros in those other languages. Still, I often hit the same wall when trying to write a Lisp macro so I know that there’s more I have to learn.
A Quick Look at Macros
First, let’s review macros for a moment to make sure we’re all on the same page. The C/C++ macros are the simplest to understand so we’ll start there. The C and C++ compilers run in two stages. First, the C preprocessor runs to expand all of your macros. Then, the compiler runs to actually compile your code. In C and C++, macros are declared using the #define command to the preprocessor. For example, you might do something like the following:
Read the rest of this entry ⇒