[erlang-questions] Erlang way for process-as-library?
Matthias Lang
matthias@REDACTED
Thu Apr 26 19:42:38 CEST 2007
ok writes:
...
> A client of the behaviour has to export those callback
> functions to the behaviour.
...
> Passing funs is no real remedy, because you want these
> functions to be replaced when the module is reloaded.
Does the following example affect your conclusion?
Eshell V5.5.2 (abort with ^G)
1> c(funs).
{ok,funs}
2> F = funs:return_fun().
#Fun<funs.0.65081764>
3> F().
version 1
ok
4> c(funs). % I edited the source before recompiling
{ok,funs}
5> F().
version 2
ok
6> c(funs).
{ok,funs}
7> F().
version 3
ok
Matthias
----------------------------------------------------------------------
-module(funs).
-export([return_fun/0]).
return_fun() ->
fun f/0.
f() ->
io:fwrite("version 1\n").
More information about the erlang-questions
mailing list