I have a module that is mainly used as a namespace. Let's call it Bla . There are other submodules that have methods with specific functions for this submodule.
However, I want to have two options:
1) import the main Bla module and use all functions directly from the submodules (do not write several imported separately)
2) import only a specific submodule of the Bla.Subbla type to use functions only from this module without importing functions from other submodules
This is what I have:
defmodule Bla do defdelegate bla_func(text), to: Bla.Subbla defdelegate bla_func(text, opts), to: Bla.Subbla end defmodule Bla do def bla_func(text), do: Bla.Subbla.bla_func(text) def bla_func(text, opts), do: Bla.Subbla.bla_func(text, opts) end
What is the right way to do this? I have two options, but I have no idea, maybe much better. Are these two options equivalent? And which one is preferable? Is there a difference in performance?
source share