On Fri, Dec 30, 2005 at 07:58:15PM +0000, [EMAIL PROTECTED] wrote:
> I'm having trouble when I'm attempting to use macrolet.  I've made a
> very small test case to illustrate the problem.
<snip>
> Here's the failure case, note that I'm using a comma-at expansion of
> "z":
> 
> * (defun foo2 (x)
>   (princ (format nil "listp(x) returns ~A." (listp x)))
>   (macrolet ((fudge (z)
>                     `(list 1 2 3 ,@z)))
>             (fudge x)))
> 
> FOO2
> 
> When foo2 is run, I get this error:
> 
> * (foo2 '(1 2 3 4 a))
> 
> Type-error in KERNEL::OBJECT-NOT-LIST-ERROR-HANDLER:  X is not of
> type LIST
>    [Condition of type TYPE-ERROR]
> 
> Restarts:
>   0: [ABORT] Return to Top-Level.
> 
> Debug  (type H for help)
> 
> (C::DYNAMIC-EXTENT-CLOSURE-ARGS (1 2 3 . X))
> Source: Error finding source:
> Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no
> longer exists:  target:compiler/ir1tran.lisp.
> 0] 0
> 
> If I change the comma-at to just just comma, look what happens:
> 
> * (defun foo2 (x)
>   (princ (format nil "listp(x) returns ~A." (listp x)))
>   (macrolet ((fudge (z)
>                     `(list 1 2 3 ,z)))
>             (fudge x)))
> 
> FOO2
> * (foo2 '(2 4 5 a))
> listp(x) returns T.
> (1 2 3 (2 4 5 A))
> 
> I don't understand why lisp doesn't believe x is a list--it is
> clearly a list.  Is this a bug or am I not using macrolet correctly?

You're using Z incorrectly.  Maybe this will help; note the FORMAT in
the definition of FUDGE:

    CL-USER> (defun foo (x)
               (macrolet ((fudge (z) 
                                 (format t "z is ~A~%" z) 
                                 `(list 1 2 3 ,@z)))
                 (fudge x)))
    CL-USER> (compile 'foo)
    z is X

    Type-error in KERNEL::OBJECT-NOT-LIST-ERROR-HANDLER:  X is not of
    type LIST
    [...]

Do you see?  When expanding FUDGE, Z has the value X, not (1 2 3 4 A).

-- Larry


Reply via email to