【发布时间】:2013-05-13 15:27:24
【问题描述】:
我有一个关于 Erlang 函数的问题。查看 Erlang shell 中的代码:
1> F1 = fun() -> timer:sleep(1000) end. #Fun<erl_eval.20.111823515> 2> F2 = fun() -> io:format("hello world~n", []) end. #Fun<erl_eval.20.111823515>
F1 和 F2 是不同的,但为什么它们都有一个标识符 #Fun<erl_eval.20.111823515>?这些神奇的数字是什么意思?
ERTS Manual中有一段话,说:
When interpreting the data for a process, it is helpful to know that anonymous
function objects (funs) are given a name constructed from the name of the
function in which they are created, and a number (starting with 0) indicating
the number of that fun within that function.
我也看不懂这一段的意思,能解释一下吗?
【问题讨论】:
标签: erlang