Dynamically invoking unexported function

Bengt Kleberg <>
Mon Jan 16 17:22:31 CET 2006


On 2006-01-16 17:06, Dominic Williams wrote:
> Hello,
> 
> I would like to invoke a local function dynamically in
> a receive, like this:
> 
>   receive
>     {Pid, Request, Arguments} ->
>       ?MODULE:Request(Arguments);    % (*)
>     ...
>   end,
> 
> which would invoke e.g.
> 
> foo({X,Y}) ->
>   ...
> 
> Unfortunately, (*) only seems to work on exported
> functions. Is that correct, and if so what is the
> rationale? If not, what am I missing?

have you tried:
{Pid, Request, Arguments} ->
        Request(Arguments);    % (*)


bengt, who would like to suggest the variable name Argument, since this 
only works on an arity 1 Request



More information about the erlang-questions mailing list