[erlang-questions] Storing funs in term files
Steve Davis
steven.charles.davis@REDACTED
Sat Apr 4 13:06:45 CEST 2009
Given that:
1> A = {echo, fun(X) -> X end}.
{echo,#Fun<erl_eval.6.13229925>}
I have a scenario where it would be useful to store funs in term
files, for example:
% contents of the term file
{echo, fun(X) -> X end}.
2>{ok, B} = file:consult("fun.term").
** exception error: no match of right hand side value
{error,{2,erl_parse,"bad term"}}
Note that although the term file contents *passes the syntax checker*,
the parser declares this to be a bad term.
Is there a way to achieve this? If not, it seems odd to me that funs
should be "second class citizens" in term files.
Thanks!
More information about the erlang-questions
mailing list