Fork me on GitHub

Hi guys, I write articles on Clojure on a daily basis taking brave clojure as a reference. Check out my latest article on Functions in Clojure: Day 4 :


@U7XS4LNSH nice effort. Here's another way to differentiate macros vs functions: What is a function? A function is a mappings of data -> data, that evaluates at run time. So, functions are used to consume and produce run-time data and side-effects. What is a macro? A macros is also a mapping of data -> data, but one that evaluates at compile time. So, macros are used to do source code transformations at compile time. Functions can also be used to manipulate s-expressions. See, for example, lines 121 to 197 here:


Heyy @U051MHSEK Thanks for the explanation. I didn't know about the compile/runtime diff b/w function and a macro.


This is also the reason why one can't pass a macro as an argument to a function. i.e. while macros are also functions of data->data, they are not "first-class", because they are meaningless in a run-time context. An unevaluated macro would be meaningless at run-time, because it can't do anything with the source code any more.


Ooh, this thread has appeared an opportune moment. Directly related to what we are discussing now ...