Heres a short overview.
Note: I wrote this on my phone and haven’t been able to test it so there may be some bugs in the sample code.
Use it for constructing blocks of code.
edit: added missing
Splices in code
macro double_input(fn, x)
# If x is an expression with side effects like `print(b)`
# we don't want to do that twice so we assign it to `z` first.
z = $(x)
@double_input div 3
# returns 1
Use it for variables assigned to in macros that you want visible externally
macro setvar(x, y)
$(esc(x)) = $(y)
Allows you to splice in code without interpolating it.
Shouldn’t be used in macros or functions for the most part. It can be however useful to use at top level if you have a large number of similar functions to define.
for op in [:(+), :(-), :(*), :(/)]
@eval Base.$(op)(x::MyType, y::MyType) = MyType($(op)(x.x, y.x))