Your own behaviours

Ulf Wiger <>
Tue Sep 25 09:30:40 CEST 2001


On Mon, 24 Sep 2001, Chandrashekhar Mullaparthi wrote:

>I tried looking at the documentation but couldn't find it - is
>it possible for a module to implement more than one behaviour??

This has been done in a few instances in the past. One example is
sasl.erl, which implements both an 'application' behaviour and a
'supervisor' behaviour. In the case of sasl.erl, it's labeled as
an 'application' behaviour, so the linter doesn't know to check
for 'supervisor' behaviour compliance.

If one wants to implement multiple behaviours with the new model
for specifying behaviours, it would have to be done in the same
way. I recommend against it. I think one module - one behaviour
is logical.



>I don't have an example of why I would need to do this but it
>occured to me that it can be quite powerful for a process to
>implement different behaviours. A bit like a class implementing
>a number of interfaces in Java.

Yes, but in Java, the class concept is central, and it'd be
awkward to have to define multiple classes in order to support
multiple types of interface. Erlang is structured differently.
Without going deeper into why, I don't think the analogy holds.

/Uffe
-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB




More information about the erlang-questions mailing list