For some reason I can’t understand the two following paragraphs from the docs:
Finally, developers should also avoid defining functions inside the
__using__/1callback, unless those functions are the default implementation of a previously defined
@callbackor are functions meant to be overridden (see
defoverridable/1). Even in these cases, defining functions should be seen as a “last resort”.
In case you want to provide some existing functionality to the user module, please define it in a module which will be imported accordingly; for example,
ExUnit.Casedoesn’t define the
test/3macro in the module that calls
use ExUnit.Case, but it defines
ExUnit.Case.test/3and just imports that into the caller when used.
Is it saying it’s better to inject imports rather than full function definitions?
In both cases it doesn’t prevent naming clashes with functions having same name in the caller, right? What is the difference?