[erlang-questions] Possible bug in process_info ?
Ulf Wiger (TN/EAB)
ulf.wiger@REDACTED
Tue Sep 26 08:39:35 CEST 2006
Tim Rath wrote:
>
> Hi,
>
> I was playing around with a macro to log some additional
> detail along with a message, and found something peculiar
> with the arity that process_info reports.
I think the best way to illustrate what's going on
is to run a call trace on the module b:
Eshell V5.5.1 (abort with ^G)
1> dbg:tracer().
{ok,<0.42.0>}
2> dbg:tpl(b,[]).
{ok,[{matched,nonode@REDACTED,6}]}
3> dbg:p(all,[c]).
{ok,[{matched,nonode@REDACTED,33}]}
4> b:test().
b:test/0 : Foo = bar
(<0.40.0>) call b:test()
b:'-test/0-fun-0-'/0
(<0.40.0>) call b:'-test/0-fun-0-'()
b:'-test/0-fun-1-'/2 : Foo = bar
(<0.40.0>) call b:'-test/0-fun-1-'([bar],"Foo = ~p")
b:'-test/0-fun-2-'/5 : Foo = bar
(<0.40.0>) call b:'-test/0-fun-2-'(1,2,3,[bar],"Foo = ~p")
ok
Funs are converted into first class functions, with
the variables inherited from the surrounding
function passed on as arguments. When you changed
the io:fwrite/2 call, you were adding references
to variables declared outside the fun. As you can
see in the above trace, those variables are passed
to the fun as function arguments following the
"official" arguments.
BR,
Ulf W
More information about the erlang-questions
mailing list