Guest User

Untitled

a guest
Jan 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
  2.  
  3. Eshell V5.8.5 (abort with ^G)
  4. 1> c(crazy_fun).
  5. {ok,crazy_fun}
  6. 2> crazy_fun:
  7. module_info/0 module_info/1 science/0
  8. 2> F = crazy_fun:science().
  9. #Fun<crazy_fun.0.71331273>
  10. 3> file:write_file("dynamite.erlfun", erlang:term_to_binary(crazy_fun:science())).
  11. ok
  12. 4> code:delete(crazy_fun).
  13. true
  14. 5> code:purge(crazy_fun).
  15. *** ERROR: Shell process terminated! ***
  16. Eshell V5.8.5 (abort with ^G)
  17. 1>
  18. User switch command
  19. --> q
  20.  
  21. %% crazy_fun module no-longer in code path:
  22.  
  23. nem@dhcp-164 ~ % erl
  24. Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
  25.  
  26. Eshell V5.8.5 (abort with ^G)
  27. 1> F = binary_to_term(element(2, file:read_file("tmp/dynamite.erlfun"))).
  28. #Fun<crazy_fun.0.71331273>
  29. 2> f().
  30. ok
  31. 3> F = binary_to_term(element(2, file:read_file("tmp/dynamite.erlfun"))).
  32. #Fun<crazy_fun.0.71331273>
  33. 4> F().
  34. ** exception error: {undef,[{#Fun<crazy_fun.0.71331273>,[]},
  35. {erl_eval,do_apply,5},
  36. {shell,exprs,7},
  37. {shell,eval_exprs,7},
  38. {shell,eval_loop,3}]}
  39. 5>
  40. User switch command
  41. --> q
  42.  
  43. %% new version, unchanged fun body
  44. nem@dhcp-164 ~/tmp % erl
  45. Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
  46.  
  47. Eshell V5.8.5 (abort with ^G)
  48. 1> c(crazy_fun).
  49. ./crazy_fun.erl:10: Warning: function version/0 is unused
  50. {ok,crazy_fun}
  51. 2> F = binary_to_term(element(2, file:read_file("tmp/dynamite.erlfun"))).
  52. ** exception error: bad argument
  53. in function binary_to_term/1
  54. called as binary_to_term(enoent)
  55. 3> F = binary_to_term(element(2, file:read_file("dynamite.erlfun"))).
  56. #Fun<crazy_fun.0.71331273>
  57. 4> F().
  58. nothing_to_see_here
  59. 5>
  60. User switch command
  61. --> q
  62.  
  63. %% updated fun body
  64. nem@dhcp-164 ~/tmp % erl
  65. Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
  66.  
  67. Eshell V5.8.5 (abort with ^G)
  68. 1> c(crazy_fun, [load]).
  69. ./crazy_fun.erl:10: Warning: function version/0 is unused
  70. {ok,crazy_fun}
  71. 2> F = binary_to_term(element(2, file:read_file("dynamite.erlfun"))).
  72. #Fun<crazy_fun.0.71331273>
  73. 3> F().
  74. ** exception error: bad function #Fun<crazy_fun.0.71331273>
  75. 4>
  76. User switch command
  77. --> q
Add Comment
Please, Sign In to add comment