fun expressions and abstract forms

Yariv Sadan yarivvv@REDACTED
Fri Aug 18 06:21:40 CEST 2006


Earlier today, I thought I made a breakthrough for Smerl when I
discovered that erlang:fun_info gives you the abstract form of fun
expressions as well as their closure environment values.

I even added APIs for adding functions using fun expressions:

C = smerl:new(foo),
smerl:add_func(C, bar, fun() -> 1+1 end),
foo:bar(). % return 2

Why did I get excited? Because this API would let Smerl users avoid
writing code snippets or having to know the abstract format.

I actually got everything to work, including embedding closure
variables in the generated functions.

Silly me, I only tested it in the Erlang shell, where everything
worked perfectly.

Later today, I wrote similar code in a compiled module, and lo and
behold, erlang:fun_info stopped giving me any useful information -- ie
abstract representation -- for fun expressions. This totally broke the
fun expression usage in Smerl.

My question is, is there any way of getting the abstract format for a
fun expression in a compiled module?

(I tried erl_parse:abstract, but it doesn't seem to handle fun
expressions, just basic values.)

Any help is appreciated,


More information about the erlang-questions mailing list