[erlang-questions] Erlang way for process-as-library?
Wed Feb 7 13:10:52 CET 2007
On 2/7/07, Emil Hellman <emil.hellman@REDACTED> wrote:
> > 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:
> I'm not sure if this would work, so feel free to criticize.
> I believe the code at the end of this email makes sure that only
> clients spawned into the 'Allowed' module would get the 'hey_mate'
> answere. Running the code:
> Eshell V5.5.3 (abort with ^G)
> 1> server:start(client).
> 2> client:middleman(foo).
> <0.32.0>I'm allright!
> 3> server ! stop.
> 4> server:start(some_other_module).
> 5> client:middleman(foo).
> <0.37.0>Damn your protected function!
> I would like to be able to protect the exported functions in a manner
> like this without having ot write the custom code. I've been thinking
> about doing a parse transform that would check if the module had
> something like:
> and then generate the that would cause these checks to be made.
> Alternatively check if the module was started in a specific
> application or maybe only protect specific exported funcitons. Would
> there be any problems with doing something like that?
I guess the real question is... why the heck would you want to do
that? What problem does that solve? Does that problem actually exist?
More information about the erlang-questions