Ok…
so if I have a behavior like:
defmodule X
@callback one(any) :: integer
@callback two(any) :: integer
end
How do I achieve a pattern like “I want to write a function that an implementor of this behavior will get by default”? I was trying:
defmodule X
@callback one(any) :: integer
@callback two(any) :: integer
def three(o, t) do one(o) + two(t) end
end
This is not right because behaviors don’t work like that… I have to use the using macro:
defmodule X
@callback one(any) :: integer
@callback two(any) :: integer
defmacro __using__ do
def three(o, t) do one(o) + two(t) end
end
end
Then I would use X instead of @behavior X so that I get the extra code that I want.
Is that correct? Is there a better way of doing this?






















