You can use 'macro-function' to tell if a symbol is defined as an
ordinary macro. But apparently there is no way to tell if a symbol is a
symbol-macro except by (eq (macroexpand-1 sym) sym). If that correct?
-- Drew McDermott
Drew McDermott <··················@at.yale.dot.edu> writes:
> You can use 'macro-function' to tell if a symbol is defined as an
> ordinary macro. But apparently there is no way to tell if a symbol is
> a symbol-macro except by (eq (macroexpand-1 sym) sym). If that
> correct?
I think you mean (not (eq ..)). But yeah, as far as I know, that's right.
Probably (nth-value 1 (macroexpand-1 sym [env])) is safer, since a symbol
macro that's defined (erroneously) to expand to itself (which would loop
infinitely, I believe) would not be detected by your test...
FWIW, normal macro expansion runs a function, but symbol
macroexpansion works by just doing a simple substitution, no execution
of user code [though such user code might happen by expanding further
macro calls, it wouldn't be in the first macroexpand-1 call], so at
least the computational cost of this particular call to MACROEXPAND-1
is relatively low and does not invoke a full Turing machine.