How to know whether a symbol represents function or macro?

血红的双手。 提交于 2020-01-14 02:28:10

问题


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


来源:https://stackoverflow.com/questions/24557669/how-to-know-whether-a-symbol-represents-function-or-macro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!