[erlang-questions] how: to serialize a function?
Mon Feb 25 21:51:38 CET 2008
1> F = fun(X) -> X * X end.
2> B = term_to_binary(F).
%%% you can send the binary to other processes
3> apply(F, ).
4> apply(binary_to_term(B), ).
On Mon, Feb 25, 2008 at 5:35 PM, Tim Fletcher <twoggle@REDACTED> wrote:
> Given an example function like so:
> > F = fun(X) -> X * X end.
> My first question is: how can I serialize (and de-serialize) that
> function completely (i.e. including its args)? I know that it's easy
> to send that function between processes/nodes, but how do I replicate
> that serialization myself?
> Next, given that I can get a string representation of the function like so:
> > erlang:fun_to_list(F).
> My second question is: what function do I use to turn that string back
> into (a proper "reference" to) the function F?
> erlang-questions mailing list
More information about the erlang-questions