Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
- Eshell V5.8.5 (abort with ^G)
- 1> c(crazy_fun).
- {ok,crazy_fun}
- 2> crazy_fun:
- module_info/0 module_info/1 science/0
- 2> F = crazy_fun:science().
- #Fun<crazy_fun.0.71331273>
- 3> file:write_file("dynamite.erlfun", erlang:term_to_binary(crazy_fun:science())).
- ok
- 4> code:delete(crazy_fun).
- true
- 5> code:purge(crazy_fun).
- *** ERROR: Shell process terminated! ***
- Eshell V5.8.5 (abort with ^G)
- 1>
- User switch command
- --> q
- %% crazy_fun module no-longer in code path:
- nem@dhcp-164 ~ % erl
- Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
- Eshell V5.8.5 (abort with ^G)
- 1> F = binary_to_term(element(2, file:read_file("tmp/dynamite.erlfun"))).
- #Fun<crazy_fun.0.71331273>
- 2> f().
- ok
- 3> F = binary_to_term(element(2, file:read_file("tmp/dynamite.erlfun"))).
- #Fun<crazy_fun.0.71331273>
- 4> F().
- ** exception error: {undef,[{#Fun<crazy_fun.0.71331273>,[]},
- {erl_eval,do_apply,5},
- {shell,exprs,7},
- {shell,eval_exprs,7},
- {shell,eval_loop,3}]}
- 5>
- User switch command
- --> q
- %% new version, unchanged fun body
- nem@dhcp-164 ~/tmp % erl
- Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
- Eshell V5.8.5 (abort with ^G)
- 1> c(crazy_fun).
- ./crazy_fun.erl:10: Warning: function version/0 is unused
- {ok,crazy_fun}
- 2> F = binary_to_term(element(2, file:read_file("tmp/dynamite.erlfun"))).
- ** exception error: bad argument
- in function binary_to_term/1
- called as binary_to_term(enoent)
- 3> F = binary_to_term(element(2, file:read_file("dynamite.erlfun"))).
- #Fun<crazy_fun.0.71331273>
- 4> F().
- nothing_to_see_here
- 5>
- User switch command
- --> q
- %% updated fun body
- nem@dhcp-164 ~/tmp % erl
- Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
- Eshell V5.8.5 (abort with ^G)
- 1> c(crazy_fun, [load]).
- ./crazy_fun.erl:10: Warning: function version/0 is unused
- {ok,crazy_fun}
- 2> F = binary_to_term(element(2, file:read_file("dynamite.erlfun"))).
- #Fun<crazy_fun.0.71331273>
- 3> F().
- ** exception error: bad function #Fun<crazy_fun.0.71331273>
- 4>
- User switch command
- --> q
Add Comment
Please, Sign In to add comment