Create fux
-module(fux).
-export([make_fun/0, version/0]).
version() -> 1.
make_fun() -> fun() -> ok end.
Start node1:
erl -sname node1
bash
Start node2 in another shell:
```erl
erl -sname node2
bash
Compile fux and load on node1.
```erl
(node1@theta)1> c(fux).
{ok,fux}
Load fux on node2.
(node2@theta)1> l(fux).
{module,fux}
Check:
(node1@theta)3> fux:module_info(attributes).
[{vsn,[151426719270796359423848501135731261286]}]
(node2@theta)6> fux:module_info(attributes).
[{vsn,[151426719270796359423848501135731261286]}]
Update fux:
-module(fux).
-export([make_fun/0, version/0]).
version() -> 2.
make_fun() -> fun() -> ok end.
Compile fux:
(node1@theta)4> c(fux).
{ok,fux}
(node1@theta)5> fux:module_info(attributes).
[{vsn,[137664929007731578445243513831488672766]}]
Make fun on node with new version:
(node1@theta)7> F = fux:make_fun().
#Fun<fux.0.54299240>
(node1@theta)9> rp(term_to_binary(F)).
<<131,112,0,0,0,66,0,103,145,77,8,58,68,121,179,49,223,94,
92,16,218,211,254,0,0,0,0,0,0,0,0,100,0,3,102,117,120,
97,0,98,3,60,138,104,103,100,0,11,110,111,100,101,49,64,
116,104,101,116,97,0,0,0,39,0,0,0,0,2>>
Load fun on node2:
(n2@theta)7> B = <<131,112,0,0,0,66,0,103,145,77,8,58,68,121,179,49,223,94,
(n2@theta)7> 92,16,218,211,254,0,0,0,0,0,0,0,0,100,0,3,102,117,120,
(n2@theta)7> 97,0,98,3,60,138,104,103,100,0,11,110,111,100,101,49,64,
(n2@theta)7> 116,104,101,116,97,0,0,0,39,0,0,0,0,2>>.
<<131,112,0,0,0,66,0,103,145,77,8,58,68,121,179,49,223,94,
92,16,218,211,254,0,0,0,0,0,0,...>>
(node2@theta)8> F = binary_to_term(B).
#Fun<fux.0.54299240>
(node2@theta)9> F().
** exception error: bad function #Fun<fux.0.54299240>
Update node2:
(node2@theta)10> l(fux).
{module,fux}
(node2@theta)11> F().
ok