[erlang-questions] Erlang way for process-as-library?

Robert Baruch autophile@REDACTED
Tue Feb 6 02:17:29 CET 2007


Thanks for all the advice -- I've decided to provide a start and  
start_link function, and let the user decide how to start the library  
up, documenting very carefully that the user *must* start the library  
before calling its functions.

Now, the next question I have is: is there an Erlang way to forbid  
"ordinary users" from calling the server's callback functions  
directly (e.g. init, terminate, and so on), while allowing gen_server  
access to them? The problem is that my exports for my library look  
like this:

% Public functions
-export([start_link/0, start/0, getBlockRange/1, getCategoryRange/1]).

% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, terminate/2]).
-export([handle_info/2, code_change/3]).

Do I really have to rely on a user's goodwill not to call the  
callbacks directly for whatever nefarious reason? :)

Thanks,

--Rob



More information about the erlang-questions mailing list