January 2020
Intermediate to advanced
532 pages
13h 31m
English
Macros are functions that accept expressions, manipulate them, and return a new expression. This is best understood with a diagram:

As we know, expressions are just abstract syntax tree representations of source code. So the macro facility in Julia allows you to take any source code and generate new source code. The resulting expression is then executed as if the source code was written directly in place.
At this point, you may wonder why we cannot use regular functions to achieve the same thing. Why could we not write a function that takes expressions, generates a new expression, and then executes the resulting expression? ...
Read now
Unlock full access