[erlang-questions] Erlang beginner questions

Frédéric Trottier-Hébert fred.hebert@REDACTED
Wed Apr 13 15:17:28 CEST 2011

As far as I know, behaviours are more than interfaces; they imply that divide between a generic and a specific bit of code, with the generic one being well-behaved and the specific one being relatively unsafe. Moreover, it also implies giving up the control of the flow to the behaviour module, restraining the callback module to specific details.

An Interface is much more generic and only has a meaning in terms of contracts in this particular case.

I might be taking a purist approach, but I think the distinction is important. I think behaviours are a rather poor tool to determine an interface itself compared to real contracts that could be enforced by the compiler or Dialyzer.

On 2011-04-13, at 09:12 AM, Mihai Balea wrote:

> Think of behaviours as interfaces, although they are not strictly enforced.
> You can define your own, here's an example: http://www.trapexit.org/Defining_Your_Own_Behaviour
> gen_udp and gen_tcp (and gen_sctp) are not, strictly speaking, behaviours. I've always wondered why they are named that way.
> The big 5 are gen_server, gen_fsm, gen_event, supervisor and application. The vast majority of OTP compliant code that I've seen is built on these five.
> You can have a module implement multiple behaviours, just be careful about callback clashes 
> Mihai
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Fred Hébert

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110413/6045565e/attachment.htm>

More information about the erlang-questions mailing list