[erlang-questions] callback module without behavior definition?

Daniel Goertzen daniel.goertzen@REDACTED
Wed Apr 6 18:46:34 CEST 2011


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)."

It seems to work fine, and the compiler doesn't complain.  Are there any
consequences to not having a behavior definition that I am overlooking?  My
whole module looks something like...


-module(mymod).
%-behavior(gen_server).
-export([start_link/0, init/1]).

start_link() ->
  gen_server:start_link(?MODULE, [], []).

init(_) ->
  do_stuff...
  {ok, []}.


My actual use-case here is to have a gen_server that "holds" a named,
read-only ets table for other processes to read.  init/1 creates the table
and loads data, and process termination makes the table go away.

Thanks,
Dan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110406/a411de25/attachment.htm>


More information about the erlang-questions mailing list