What situation causes re-expansion of macros when compiling?
I can't narrow this effect down to a small shareable piece of code, I
was hoping that someone with knowledge of how Lispworks expands macros
at compile-time could give me clues as to what to look for.
I have some code that, (and it's a long story), deliberately expands
into macrolets and macro forms. It's quite crazy; but there's a point
to it, and it basically works.
The thing is, when running a form interpreted it's just slow but runs.
However, when compiling it, forms beyond a certain complexity can take
forever. The reason seems to be that - in compile mode only - when
recursing through forms, it seems to macroexpand certain inner forms
again, an effect that goes geometric as it works down the tree. This is
re-expansion of the same macros, with the same inputs, in the same
environment, to the same result.
I realize that that the spec says nothing about when macros are expanded
or how many times, so I am not complaining about the implementation's
behavior.
What I *would* like to know if there is a known or knowable pattern to
this behavior. I'd like to alter the code generation on my end to avoid
the exponential rise in expansion time as complexity goes up.
What tends to make compiled code macroexpand the same form more than
once? If possible, what's the best way to mitigate this?
Thanks,
Matt