[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Morrison at UTAH-20
- Subject: backquote query
- From: Robert W. Kerns <RWK at MIT-MC>
- Date: Mon ,11 Jan 82 17:44:00 EDT
- Cc: Lisp-Forum at MIT-AI
- In-reply-to: The message of 11 Jan 82 11:06-EST from Don Morrison <Morrison at UTAH-20>
[Sorry for the incomplete message]
I'm not sure what your problem with BACKQUOTE is, so I'll try to touch
all the bases. Some of this may be obvious.
Are you clear on what they mean? The meaning of `(FOO ,BAR) is to
perform the same as (LIST 'FOO BAR). Exactly what code is generated
is not material to the purpose. You can look at what it does turn into
by typing '`(foo ,bar), which would show you that it doesn't happen all
You don't want to cons up a backquote expression in a macro-defining
macro. You want to cons up a piece of code which produces a list of a
specific form. For this, you use nested backquotes. For example:
(DEFMACRO DEF-NIL-CALLER (NAME SIZE)
`(DEFMACRO ,NAME (FUN)
`(,FUN ,@(MAKE-LIST ,SIZE))))
(DEF-NIL-CALLER CALL-5-NILS 5)
==> (NIL NIL NIL NIL NIL NIL)
If you need more info about how backquotes nest, see the discussion in
the LISP Machine manual (preferably a recent one).
Another way you may be getting confused is by looking at what they read
to in the compiler in MACLISP, where it does indeed expand them at READ
time for efficiency. There is nothing wrong with this, because there
is absolutely no need to cons up commas and backquotes in your code;
just use nested backquotes.
Or you may be looking at the MACROEXPANDed result in the interpreter,
perhaps with the macro having been DISPLACE'ed. Again, type '`(FOO
,BAR) to see what it really read as.
I some of this related to your problem.