[erlang-questions] callback module without behavior definition?

Attila Rajmund Nohl attila.r.nohl@REDACTED
Sat Apr 23 09:48:23 CEST 2011


2011/4/23, Ryan Zezeski <rzezeski@REDACTED>:
> On Wed, Apr 6, 2011 at 12:46 PM, Daniel Goertzen
> <daniel.goertzen@REDACTED>wrote:
>
>> One thing that has bothered me about implementing gen_servers is that I
>> have to create empty stubs for the callbacks that I don't need.  Today I
>> made a gen_server that only needs init/1, so instead of creating all those
>> stubs I just commented out the behavior definition
>> "-behavior(gen_server)."
>>
>>
> Daniel,
>
> The _Erlang Programming_ book actually says **not** to implement callbacks
> you don't need. (pp274)  I think that makes sense and is the advice I have
> followed.  However, most people tend to implement all the callbacks even if
> they don't use them for anything.  In fact, I think that's the recommended
> way in _OTP in Action_.  So it seems not even the veterans can agree on this
> topic.

Implementing all the callbacks gets rid of warnings and can still
produce an error log if unexpectedly called.



More information about the erlang-questions mailing list