It’s not really metaprogramming, other than that the person who implemented@. was metaprogramming. Crash course:
A macro (@something) takes an expression as input, returns another expression and evaluates it.
So when you write @. x^2 - 2 * y + f(x), you give @. the argument :(x^2 - 2 * y + f(x)). The internal logic of @. looks at each operator and dots it, and thus returns :(x.^2 .- 2 .* y .+ f.(x)), which is now evaluated, so @. x^2 - 2 * y + f(x) is equivalent to x.^2 .- 2 .* y .+ f.(x).
Thank you! Oscar for confirming my interpretation, John for the useful advice re: @macroexpand. Your replies were very helpful. I will mark Gustaphe’s reply as solution - I hadn’t realized! Appreciate it.
And just in case you (or anyone else) hasn’t seen it, this blog post gives a really excellent explanation of why you’d want to dot every operator in an expression.