Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test if a piece of code refers to a macro in Clojure?

Tags:

clojure

In clojure is there something like "is-macro?" to test to see if something is a macro?

like image 688
yazz.com Avatar asked Dec 03 '25 08:12

yazz.com


1 Answers

Given a var, its metadata can tell you whether it's a macro:

(:macro (meta #'when))
=> true
(:macro (meta #'identity))
=> nil
like image 183
Justin Kramer Avatar answered Dec 06 '25 07:12

Justin Kramer