do ... end
is not necessarily a function body. It's generic syntax, which when used with a macro, passes the AST (abstract syntax tree) of its contents to the macro. Here's a demonstration:
defmodule A do
defmacro a(args) do
IO.inspect args
end
def main do
a do
1 + 2
end
end
end
A.main
Output:
[do: {:+, [line: 8], [1, 2]}]
So it's just the AST of the body of the block, passed as a keyword list with the key do
.
create
then is just a macro which accepts two arguments: the first is table, and the second is the do ... end
block. The macro then transforms the block and executes it. You can see the source code of the function for more details.