[erlang-questions] Erlang code reuse

Anthony Ramine n.oxyde@REDACTED
Fri Aug 22 20:41:22 CEST 2014


I don’t see how could any supervisor implementation be extendable in a way that allows all the modifications done in supervisor2.

You would have to make the related parts of the code extendable directly in the implementation, just as you would do in Erlang if such extensibility was wanted.

-- 
Anthony Ramine

Le 22 août 2014 à 20:35, Tyler Margison <kolorahl@REDACTED> a écrit :

> 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 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 <huxili@REDACTED> wrote:
> Hello all,
> 
> I am surprised to see the way the following module is coded when studying rabbit MQ server:
> 
> https://github.com/rabbitmq/rabbitmq-server/blob/master/src/supervisor2.erl
> 
> 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
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list