murtaza52
murtaza52

Reputation: 47431

how to programatically check for reader macros

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

Upvotes: 0

Views: 57

Answers (1)

Joost Diepenmaat
Joost Diepenmaat

Reputation: 17773

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.

Upvotes: 3

Related Questions