[armedbear-devel] compiled MACROLET fails to expand in DEFUN/DEFMETHOD forms

Mark Evenson evenson at panix.com
Mon Jun 21 13:07:45 UTC 2010


The following form fails to compile correctly:

(macrolet ((output-var (var)
              `(format t "var = ~A~%" ,var)))
   (defun baz (bat)
     (output-var bat)))

When the above form has been compiled and loaded

   CL-USER> (baz 3)

errors by complaining.

   The function OUTPUT-VAR is undefined.

Interestingly abcl-0.12.0 behaves correctly, but abcl-0.15.0 fails (For 
some reason, I don't currently have abcl-0.{13,14} handy to test).

I distilled this bug down from trying to compile CXML, so this is a 
"real-world" problem.  CXML bombs on compiling its "xml/xml-parse.lisp" 
at this point:

…
(macrolet ((with-context ((validator) &body body)
              `(let ((*ctx* (context ,validator))
                     (*validate* t))
                 (with-scratch-pads ()   ;nicht schoen
                   , at body))))
   (defmethod sax:start-element ((handler validator) uri lname qname 
attributes)
     uri lname
     (with-context (handler)
       (validate-start-element *ctx* qname)
       (process-attributes *ctx* qname attributes)))
…

with

Wrong number of arguments for CXML::HANDLER.
    [Condition of type PROGRAM-ERROR]

I assume that my "distilled" version has the same cause, namely that the 
precompiler is not expanding macros properly for function/method 
definitions in top-level MACROLET forms, but I explicitly mention my 
root problem here if the slightly different error turns out to provide a 
clue that I have missed.

-- 
"A screaming comes across the sky.  It has happened before, but there
is nothing to compare to it now."




More information about the armedbear-devel mailing list