[erlang-questions] hierarchical behaviour doesn't seem to work ?
Attila Rajmund Nohl
attila.r.nohl@REDACTED
Wed Dec 14 10:35:11 CET 2011
2011/12/13, Harald Welte <laforge@REDACTED>:
[...]
> To me, it seems most logical that you would want to implement levels of
> common functionality in a behaviour, and "sub-class" a number of different
> implementations off such a behaviour. And since all of it should be OTP
> compliant, that custom behaviour itself would be based on some OTP
> behaviour like gen_server, gen_fsm, etc.
>
> Any comments? Am I misunderstanding something here? Thanks!
With behaviours you can "inherit" interface, but can't implement
implementation. My rather nasty solution in similar cases was to put
the common (in your case, the handle_call) code into a header file and
include this file in the modules. This way I could avoid code
duplication.
More information about the erlang-questions
mailing list