Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang: multiple behaviors defined in the same module?

Tags:

erlang

Q: I'd like to have an idea of the pros and cons of defining multiple behaviors in the same module file.

E.g.

 -module(someapp_sup).
 -behavior(supervisor).
 -behavior(application).

Using this sort of layout, I can save a module file whilst not loosing much on the maintainability side (the whole application is started through someapp_sup:start()).

like image 672
jldupont Avatar asked Dec 03 '09 18:12

jldupont


1 Answers

As long as the callbacks defined in the behavior don't conflict with a callback of another behavior (say you defined your own behavior, for example) then there's nothing wrong with doing this other than potentially more confusing code. Obviously you can curb that with some well placed comments and laying the code out sensibly in the file.

like image 135
rfunduk Avatar answered Nov 14 '22 02:11

rfunduk