clojureMacros


Syntax

  • The ' symbol used in the macroexpand example is just syntactic sugar for the quote operator. You could have written (macroexpand (quote (infix 1 + 2))) instead.

Remarks

Macros are just functions that run at compile time, i.e. during the eval step in a read-eval-print-loop.

Reader macros are another form of macro that gets expanded at read time, rather than compile time.

Best practice when defining macro.

  • alpha-renaming, Since macro is expand binding name conflict could arise. Binding conflict is not very intuitive to solve when using the macro. This is why, whenever a macro adds a binding to the scope, it is mandatory to use the # at the end of each symbol.