January 2020
Intermediate to advanced
532 pages
13h 31m
English
Just like functions, macros can also take arguments. In fact, taking an argument is the most common occurrence for a macro. The simplest type of argument is literals, such as numbers, symbols, and strings.
In order to utilize these arguments in the returned expression, we can use the interpolation technique that we learned in the last section. Consider the following code:
macro hello(n) return :( for i in 1:$n println("hello world") end )end
The hello macro takes a single argument, n, which is interpolated into the expression when the macro is run. As before, we can just invoke the macro as follows:

As we learned ...
Read now
Unlock full access