[erlang-questions] Re: callback module without behavior definition?

Frédéric Trottier-Hébert fred.hebert@REDACTED
Wed Apr 6 18:50:17 CEST 2011


You could alternatively just give the table (either with a heir or just giving it with ets:give_away/3) to a supervisor or some system process that should never die.

On 2011-04-06, at 12:46 PM, Daniel Goertzen 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)."
> 
> 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.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

--
Fred Hébert
http://www.erlang-solutions.com





More information about the erlang-questions mailing list