[erlang-questions] better ct_expand and some intricate problems

Vance Shipley vances@REDACTED
Sun Jan 29 22:08:42 CET 2012


On Sat, Jan 28, 2012 at 06:39:52PM +0100, Ulf Wiger wrote:
}  Funs from erl_eval _can_ actually be abstracted using erl_eval:fun_data/1.
}  
}  Too bad erl_parse:abstract/1 isn't aware of that…

Indeed.  Neither is the Erlang Pretty Printer.  Not without converting
the fun_data to the proper abstract expression form for a fun():

   1> {ok, Tokens, _} = erl_scan:string("fun () -> ok end."),
   1> {ok, ExprList} = erl_parse:parse_exprs(Tokens),
   1> {value, Fun, _} = erl_eval:exprs(ExprList, []),
   1> {fun_data, _, Clauses} = erl_eval:fun_data(Fun),
   1> AbsExpr = {'fun', 0, {clauses, Clauses}},
   1> io:put_chars(erl_pp:expr(AbsExpr)).                    
   fun() ->
          ok
   endok


-- 
	-Vance



More information about the erlang-questions mailing list