Dynamically add module functions in __using__ macro

Thanks for everyone’s replies.

@jswny I did try that but doesn’t work as you’d expect:

defmodule A do
  defmacro __using__(_opts) do
    quote do
      import A
    end
  end
  
  def foo(), do: "Foo"
end

defmodule B do
  use A
end

You can access A.foo() but not B.foo() :thinking: Is this using do.. end DSL doing something special, compared to defmacro __using__(_)?

@idi527 defoverridable is indeed what I need to use to make an injected function overridable, but that’s only one part of the puzzle :slight_smile:

My goal is to have the functions accessible on the original module, inject them into the module that’s using it via use and make them overridable: