如何知道符号代表功能还是宏? [英] How to know whether a symbol represents function or macro?

查看:108
本文介绍了如何知道符号代表功能还是宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为功能/宏组成编写宏(可以混合使用).在宏内部,我必须处理代表函数的符号和以不同方式命名宏的符号.这是因为结果函数必须可以使用任意数量的参数(如果组合中的最低"函数可以),并且我不能将apply应用于宏.我的问题:如何确定给定符号代表的是函数还是宏?

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?

推荐答案

宏:

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

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

功能:

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

这篇关于如何知道符号代表功能还是宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆