[erlang-questions] Getting code from closures

Thomas Lindgren thomasl_erlang@REDACTED
Tue Dec 3 20:03:36 CET 2013


I want to look at the closure code to investigate some stupid compiler tricks.

Best,
Thomas



On Tuesday, December 3, 2013 1:30 PM, Anthony Ramine <n.oxyde@REDACTED> wrote:
 
No there isn’t.
>
>Why do you need that, out of curiosity?
>
>-- 
>Anthony Ramine
>
>
>Le 3 déc. 2013 à 13:14, Thomas Lindgren <thomasl_erlang@REDACTED> a écrit :
>
>> Hi guys,
>> 
>> Before I start hacking on something, I thought I'd ask whether there already is a standard way to get the original code from a compiled fun/closure. (I know you can get it for interpreted funs by using fun_info.)
>> 
>> E.g., for code like this:
>> 
>> -module(a). 
>> -compile(export_all).
>> adder(N) -> fun(X) X+N end.
>> 
>> I'd like to be able to write something like this:
>> 
>> > c(a), F = a:adder(3), magic:get_code(F).
>> {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, 0,'X'},{var,0,'N'}}]}], [{'N', 3}]}  %% AST of fun F with free var env
>> 
>> Or the equivalent.
>> 
>> Best,
>> Thomas
>> 
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131203/9c3d25a7/attachment.htm>


More information about the erlang-questions mailing list