I will be short:
defmodule A do
use B
def func1 do
callback = &func2/1
# then I need to send callback to another function call
end
# that's all, there is no definition of func2 in module A
# all your func2 definitions belongs to module B
# but this way it will fail with no error
# just func2 will never be called
end
So, pls, read “comments” section of code example if u have not done it yet.
The workaround is that I need to define function func2 in module A and arity doesn’t matter.
I was also playing with on_definition hook to understand what’s going on and everything looks fine:
def on_def(_env, kind, name, args, guards, body), do:
IO.puts("Defining #{kind} named #{name}")
It shows me a definition of func2 right at the start where I was expecting it to be
Should I dive into sources of Elixir or is there some Unhidden Truth somewhere on this topic?
Is there something with compiler?
Yep, I forgot, module B just contains using macro with quoted definition of func2