This is a collection of blog entries written while learning Lisp. It is posted in the order written so you probably want to jump to the first post.

Thursday, October 18, 2007

Practical Common Lisp Chapter 8 : Macros

Say this three times fast:

Common Lisp doesn't support macros so every Lisp programmer can create their own variants of standard control constructs any more than C supports functions so every C programmer can write trivial variants of the functions in the C standard library.

This chapter introduces us again to macros (and from the looks of it there will be more introductions in future chapters). It had a nice story that tried to show how one might want macros and then walked you through making the macro 'do-primes'. The more interesting part of the chapter was the sections on the leaks. It mentions that there are three types of leaks, but never explicitly lists them. Here is what I think they are:
  • multiple-evaluation leak
  • out of order leak
  • not using unique names leak

It was interesting to learn about the solutions presented and I am curious if there is any way to apply that knowledge to my c/c++ programming.

I went back in the book to chapter 2 and looked up how to reindent an entire function (C-c M-q) which came in handy as we kept adding and removing things from the macro.

No comments: