SOLVED: Lisp: macro calling a function works in interpreter, fails in compiler (SBCL + CMUCL)

Posted by ttsiodras on Stack Overflow See other posts from Stack Overflow or by ttsiodras
Published on 2011-11-15T15:24:50Z Indexed on 2011/11/15 17:51 UTC
Read the original article Hit count: 310

Filed under:
|

As suggested in a macro-related question I recently posted to SO, I coded a macro called "fast" via a call to a function (here is the standalone code in pastebin):

(defun main ()
  (progn
    (format t "~A~%" (+ 1 2 (* 3 4) (+ 5 (- 8 6))))
    (format t "~A~%" (fast (+ 1 2 (* 3 4) (+ 5 (- 8 6)))))))

This works in the REPL, under both SBCL and CMUCL:

$ sbcl
This is SBCL 1.0.52, an implementation of ANSI Common Lisp.
...
* (load "bug.cl")
22
22

$

Unfortunately, however, the code no longer compiles:

$ sbcl
This is SBCL 1.0.52, an implementation of ANSI Common Lisp.
...
* (compile-file "bug.cl")
...
;   during macroexpansion of (FAST (+ 1 2 ...)). Use *BREAK-ON-SIGNALS* to
;   intercept:
;
;    The function COMMON-LISP-USER::CLONE is undefined.

So it seems that by having my macro "fast" call functions ("clone","operation-p") at compile-time, I trigger issues in Lisp compilers (verified in both CMUCL and SBCL).

Any ideas on what I am doing wrong and/or how to fix this?

© Stack Overflow or respective owner

Related posts about macros

Related posts about lisp