[erlang-questions] Anonymous functions or callback module - Performance
Thu Nov 29 01:38:50 CET 2012
On Wed, Nov 28, 2012 at 05:29:23PM +0100, lvaro wrote:
> A possible solution can be defining the list of functions as:
> FList = [F1 = fun (X) -> X+1 end, ..., F3 = fun(X) -> X *2 end]
> (of course these functions do not invoke any code that could be hot swapped)
Just beware of reloading the module they are defined in. After the
second reload, they'll be purged anyway and calling them will fail.
I'm not sure that I understand your problem correctly, but if you
must gather a collection of functions to call in a pipeline, and you
want to ensure that they all "stick together" for each use of the
pipeline, even during arbitrary code-reloads, then you probably must
put them in a unique module or modules for each version of the
pipeline. You'll have to manage the module name generation and
cleaning up old modules manually though.
More information about the erlang-questions