Re: Question about design, defmacro, macrolet, and &environment

From: Peter Seibel (peter_at_javamonkey.com)
Date: 11/06/03


Date: Thu, 06 Nov 2003 19:46:27 GMT

Damien Kick <dkick1@email.mot.com> writes:

> Peter Seibel <peter@javamonkey.com> writes:
>
> > The best time to ask questions on c.l.l is after you've done steps 1
> > and 2. And show us what you came up with in those steps.
>
> I'll try and expand on this a bit.
>
> Last time, when I wrote the following, I was attempting to understand
> what was happening during the macroexpansion.
>
> > PG-USER[20]> (LET ((FOO 'X))
> > (MACROLET
> > ((DEFAULT-VAR NIL `(T FOO)))
> > (macroexpand '(EXPECT-1))))
> > (EXPECT-1-LEMMA) ;
> > T
>
> > ;;;It would seem that the macrolet is not being expanded within
> > ;;;expect-1 like I thought it should be.

Okay, so I think your immediate problem is that MACROLET defines a
*local*, i.e. lexical macro binding. Since there's no reference to
DEFAULT-VAR within the lexical scope of the MACROLET form, there's no
way the local binding of DEFAULT-VAR is going to have any affect. (You
seem to be expecting that the local definition of DEFAULT-VAR is going
to affect the call to MACROEXPAND-1 *inside* the definition of
EXPECT-1; that's not how it works.)

More generally, I think you still need to pull back and show us 1) the
code you want to be able to write and 2) the code you would have to
write to do achive the desired result without the macro. Maybe I'm
just dense but I have no idea what a program that uses EXPECT is going
to look like (1) and what it would do (2). I suspect you're making
this more complicated than it needs to be but without knowing what
you're trying to do, at a high level, it's hard to say.

-Peter

-- 
Peter Seibel                                      peter@javamonkey.com
         Lisp is the red pill. -- John Fraser, comp.lang.lisp