<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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.<div><br></div><div>An Interface is much more generic and only has a meaning in terms of contracts in this particular case.<br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div></div></span></span></div></span></div></span></span>
</div>
<div>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.</div><div><br></div><br><div><div>On 2011-04-13, at 09:12 AM, Mihai Balea wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>Think of behaviours as interfaces, although they are not strictly enforced.<br>You can define your own, here's an example: <a href="http://www.trapexit.org/Defining_Your_Own_Behaviour">http://www.trapexit.org/Defining_Your_Own_Behaviour</a><br><br>gen_udp and gen_tcp (and gen_sctp) are not, strictly speaking, behaviours. I've always wondered why they are named that way.<br><br>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.<br><br>You can have a module implement multiple behaviours, just be careful about callback clashes <font class="Apple-style-span" color="#006312"><font class="Apple-style-span" color="#144FAE"><br></font></font><br>Mihai<br><br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></div></blockquote></div><br></div><div><div>--</div><div>Fred Hébert</div><div><div><a href="http://www.erlang-solutions.com">http://www.erlang-solutions.com</a></div></div><div><br></div></div></body></html>