这是程序
-module(fun_param).
-export([start/0, partition_parallel/2]).
partition_parallel(F, Es) ->
Parent = self(),
Running = [{spawn_monitor(fun() -> Parent ! {self(), F(E)} end), E, helloworld} || E <- Es].
start()->
partition_parallel(
fun (C) ->
io:format("hello:~p~n", [C])
end, [1,2,3]).
并使用recon_trace跟踪程序
recon_trace:calls({fun_param, '_', fun(_) -> return_trace() end}, 2000, [return_to, {scope, local}]).
有一些输出我不明白。
4:22:12.026917 <0.161.0> fun_param:'-partition_parallel/2-lc$^0/1-0-'([1,2,3], #Fun<fun_param.0.111727472>, <0.161.0>)
4:22:12.027101 <0.161.0> fun_param:'-partition_parallel/2-lc$^0/1-0-'([2,3], #Fun<fun_param.0.111727472>, <0.161.0>)
4:22:12.027327 <0.161.0> fun_param:'-partition_parallel/2-lc$^0/1-0-'([3], #Fun<fun_param.0.111727472>, <0.161.0>)
4:22:12.027475 <0.161.0> fun_param:'-partition_parallel/2-lc$^0/1-0-'([], #Fun<fun_param.0.111727472>, <0.161.0>)
4:22:12.027581 <0.161.0> fun_param:'-partition_parallel/2-lc$^0/1-0-'/3 --> []
4:22:12.027704 <0.161.0> '--> fun_param:'-partition_parallel/2-lc$^0/1-0-'/3
'-partition_parallel/2-lc$^0/1-0-'
是什么意思,特别是lc$^0/1
?- 这些参数是从哪里来的?
([1,2,3], #Fun<fun_param.0.111727472>, <0.161.0>)
1条答案
按热度按时间lskq00tm1#
这篇文章描述得很好:How to read/decode temporary function names of list comprehension in Erlang when debugging
论点
细分如下:
[1,2,3]
传递给匿名函数的参数#Fun<fun_param.0.111727472>
在partition_parallel
中定义的已编译匿名函数<0.161.0>
执行函数的进程的pid