如何编程检查读取器宏 [英] how to programatically check for reader macros

查看:138
本文介绍了如何编程检查读取器宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以包含任意数据的向量。我想检查任何元素是一个读者宏,我该如何做?



(is-reader-macro? ; DateTime 2012>); => true

解决方案



一旦字符串读取,你不能通过结果数据来确定读取器结构是创建它。您刚刚读取的数据项不是阅读器宏,而只是数据。



在您的具体示例中,您所获得的是jodatime DateTime对象的打印表示,其不能被读取 - #< ...> 构造是为了防止这种情况。打印的实际对象只是一个jodatime DateTime对象,而不是阅读器宏。


I have a vector which can contain arbitrary data. I want to check of any of the element is a reader macro, how do I do that ?

(is-reader-macro? #<DateTime 2012>) ;=> true

Thanks, Murtaza

解决方案

Once a string is read you cannot tell by the resulting data what the exact reader construct was that created it. The data item you just read is not a reader macro, it's just data.

In your specific example, what you've got is the printed representation of a jodatime DateTime object, which cannot be read - the #< ... > construct is meant to prevent that. The actual object that prints like that is just a jodatime DateTime object, not a reader macro.

这篇关于如何编程检查读取器宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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