[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using Macros in Lisp
- To: firstname.lastname@example.org.COM
- Subject: Re: Using Macros in Lisp
- From: Kevin Gallagher <Gallagher@gilgamesh.cs.umass.edu>
- Date: Wed, 6 Mar 91 20:04:32 EST
- Reply-to: Gallagher@gilgamesh.cs.umass.edu
- Sender: Gallagher@Gilgamesh
Bill St. Clair <email@example.com.COM> writes:
> I liked Drew McDermott's (and somebody else whose name I've forgotten
> at the moment) "Artificial Intelligence Programming".
[The authors of AI Programming are Charniak, Riesbeck & McDermott]
I think a contributing factor to the misunderstanding of macros is the
way they are described in many lisp texts (including "AI Programming",
2nd edition). For example, "Macros are a special type of Lisp function.
They differ from the others in that they go through not one but two
rounds of evaluation."
This starts people off with the misconception that macros are functions.
They are not functions, they are a source code transformation mechanism.
(CLtL is careful to avoid this mistake, but I don't recommend referring
a novice lisp programmer to that text to learn lisp.) Failure to grasp
this transformational nature of macros leads to the well known macro
errors: accidently shadowing local variables, macro functions with side
Another problem with the presentation of macros is that they are usually
introduced before backquote. This hides the notion of macros as a
source to source transformation beneath many layers of list, cons and
"AI Programming" does have lots of examples, though.