erlang:fun_info behaving strangely

Daniel Kwiecinski daniel.kwiecinski@REDACTED
Mon Aug 31 17:32:05 CEST 2009


Hi

    Can somebody explain the difference in results of calling the same code
directy from erlang console as opposite to calling it via defined module:

1. direct console call
*> erlang:fun_info(fun(A) -> A+1 end).
[{pid,<0.33.0>},
 {module,erl_eval},
 {new_index,2},
 {new_uniq,<<83,63,182,157,53,152,27,64,224,39,165,36,92,
             123,196,191>>},
 {index,6},
 {uniq,13229925},
 {name,'-expr/5-fun-2-'},
 {arity,1},
 {env,[[],
       {value,#Fun<shell.7.113407251>},
       {eval,#Fun<shell.24.81044707>},
       [{clause,1,
                [{var,1,'A'}],
                [],
                [{op,1,'+',{var,1,'A'},{integer,1,...}}]}]]},
 {type,local}]*

2. calling from defined module
*-module(test).
-export([foo/0]).
foo() -> **erlang:fun_info(fun(A) -> A+1 end).*

*> test:foo().
[{pid,<0.33.0>},
 {module,test},
 {new_index,0},
 {new_uniq,<<229,228,162,67,57,100,131,208,221,10,225,109,
             150,95,53,238>>},
 {index,0},
 {uniq,133275216},
 {name,'-foo/0-fun-0-'},
 {arity,1},
 {env,[]},
 {type,local}]*

Both functions are local but only the one defined directly in console had
environment.


Many Thanks in advance for any help on this.,
Daniel Kwiecinski


More information about the erlang-questions mailing list