I don't think what you want is possible, but you can do something similar if you can require the use of a parse transform. See the ms_transform implementation used by ets:fun2ms/1. <span></span><br><br>On Tuesday, January 22, 2013, Tyron Zerafa  wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Erlang:fun_info(F) is returning the function body because it is constructed in the shell which essentially passes the entire code tree to the erl_eval module for execution. If you call this for a function constructed in a module, you won't get this tree. <div>

<br></div><div>I need something along these lines that work for functions constructed in modules rather than the shell. </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 22, 2013 at 8:05 PM, Gianfranco Alongi <span dir="ltr"><<a href="javascript:_e({}, 'cvml', 'gianfranco.alongi@gmail.com');" target="_blank">gianfranco.alongi@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is this what you are after?<div><br></div><div>1> F = fun(X,Y) -> X + Y end.#Fun<erl_eval.<a href="tel:12.107821302" value="+12107821302" target="_blank">12.107821302</a></div>

<div>>2</div><div><br></div><div>2> erlang:fun_info(F).</div><div>  [{pid,<0.31.0>}, {module,erl_eval}, {new_index,3}, {new_uniq,<<251,3,184,152,93,16,176,57,2,110,24,202,39,             247,72,160>>}, {index,12}, {uniq,107821302}, {name,'-expr/5-fun-3-'}, {arity,2}, {env,[[],       {value,#Fun<shell.7.13242446>},       {eval,#Fun<shell.24.85755477>},       [{clause,1,                [{var,1,'X'},{var,1,'Y'}],                [],                [{op,1,'+',{var,1,'X'},{var,1,...}}]}]]}, {type,local}]</div>


<div>3> </div><div><br></div><div><br><div class="gmail_quote"><div><div>On Tue, Jan 22, 2013 at 6:21 PM, Tyron Zerafa <span dir="ltr"><<a href="javascript:_e({}, 'cvml', 'tyron.zerafa@gmail.com');" target="_blank">tyron.zerafa@gmail.com</a>></span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">F = fun(X,Y) -> X+Y end,<div><div><br></div><div>In the above statement, F is just a function reference. Can I get the syntax, code tree or anything else from this variable? All I need is to extract the syntax out of a function reference. Any ideas how I can achieve this?</div>



</div><div><br></div><div>The following convert a fun string into an actual fun. I need something the other way round, any ideas ??</div><div><br></div><div><br></div><div>{ok,Tks,_} = erl_scan:string(FunString),</div>
<div>{ok,E} = erl_parse:parse_exprs(Tks),</div><div>{value,Funs,_} = erl_eval:exprs(E,[]) </div><div><br></div><div>Thanks :)</div></div>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="javascript:_e({}, 'cvml', 'erlang-questions@erlang.org');" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best Regards,<div>Tyron Zerafa</div>
</div>
</blockquote>