[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Why does my Macro get expanded 8 times?
Date: Fri, 1 Jul 88 14:18 PDT
This is a known problem in the current Lisp compiler. Our best and
brightest have failed in their attempts to fix it (and we have tried
several times). The problem is inherent in the way "phase-1" of our
compiler is structured; the only good solutions we know of require
completely scrapping phase-1, and all other solutions fail in one way or
another. We hate this as much as you do, but I regret to say that
you'll have to live with it for a while. Sorry.
I have the following function, which is automatically generated
from a Prolog query (my own Prolog compiler).
(DEFUN TOP-LEVEL (MODE)
(QUERY SIMPLE-EXAMPLE ((P C)) (:STATISTICS? T :SELECTIVE-BACKTRACKING? T :FAILURE
(PRINT-STATISTICS *SOLUTION-FAILURES* *GOAL-FAILURES* *SELECTIVE-GOAL-FAILURES* *UNIFICATION-FAILURES*)
(COND ((Y-OR-N-P "Do you want another solution? "))
(T (THROW :SUCCEED
QUERY is a macro defined as:
(defmacro QUERY (name query (&key (statistics? t)
(compile-query name (symbol-value name) query success failure statistics?
Where COMPILE-QUERY is a function which actually produces a hairy amount
of Lisp code. If the variable CODE is set to the list (DEFUN TOP-LEVEL (MODE) ...)
and I do a (compile (eval CODE)), my function COMPILE-QUERY actually gets called
*eight* times from the following routines:
This is real bad because COMPILE-QUERY might take a long time to run. It also
might generate different code each time (like different GENSYM'ed variables).
In my case it doesn't, but I might like to in the future. What is particularly
annoying is that if it prints out warning messages then I get *eight* copies
of each message. This is a bug which should be fixed.
Are you using 1compiler:warn0 to print your warning messages? Just using
1format0 will not work.