[erlang-questions] Erlang code reuse
Fri Aug 22 20:35:52 CEST 2014
I'm not an Erlang expert, so others are more than welcome to correct me on
this, but I do not believe Erlang allows "code reuse" in the manner you are
suggesting. Erlang has behaviors, which are modules that define an
interface and may have additional functionality of their own (see
gen_server), but there is no way to inherit from a module and override
select functions. I feel like this isn't a common scenario, though. In all
of my own projects I very rarely, if ever, find myself re-writing entire
modules to suit my own needs.
PS: I thnk Elixir <http://elixir-lang.org/> might be able to do this, but I
haven't looked at the documentation in-depth for a while and I may be wrong.
On Thu, Aug 21, 2014 at 10:56 AM, Huxi Li <> wrote:
> Hello all,
> I am surprised to see the way the following module is coded when studying
> rabbit MQ server:
> It is a duplication of erlang's supervisor.erl with minor changes.
> So my question is : Are there better ways of code reuse in erlang without
> duplication of code as found in the above example ? Some sort of
> polymorphism ?
> Thanks in advance.
> Huxi LI
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions