How to know whether a symbol represents function o

2019-05-21 08:54发布

问题:

I'm writing a macro for function / macro composition (mixed combinations are possible). Inside of the macro I have to treat symbols which represent functions and those that name macros differently. It is because result function must work with any number of arguments (if 'lowest' function in composition can), and I cannot apply apply to macros. My question: how to determine what a given symbol represents: function or macro?

回答1:

Macro:

CL-USER 8 > (macro-function 'bar)
NIL

CL-USER 9 > (macro-function 'lambda)
#<Function LAMBDA 41100B7E94>

Function:

CL-USER 15 > (and (fboundp '+)
                  (not (macro-function '+))
                  (not (special-operator-p '+)))
T