I’m curious how the with
macro is written, so I opened the Kernel.SpecialForms
module here: https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/kernel/special_forms.ex
This appears to have all the documentation for the SpecialForms macros, but no the implementation. with
looks like this in the module:
defmacro with(args), do: error!([args])
The error!/1
macro has this in it "Elixir's special forms are expanded by the compiler and must not be invoked directly"
. So I understand what’s happening (I think!). This stop with
from being called like Kernel.SpecialForms.with ...
, and the macro expansion seems to happen differently, but I’m still curious of the implementation, and I can’t seem to find this macro defined anywhere else. What’s happening here? Why is this macro different? Where’s the actual source code of with
?