[erlang-bugs] Inconsistency in erl_syntax

Hans Svensson <>
Fri Jan 10 12:12:42 CET 2014


Hi,

I've struggled a bit with erl_syntax lately, and I find it confusing to 
say the least. I can't put my finger on exactly what is the error, but 
taken together the situation is weird.

First the forms returned by the parser (for example what you get in a 
parse transform) differ a bit.
If you have the statement: fun x/1
The form you get is: {'fun',10,{function,x,1}}
However, the statement: fun m:x/1
gives you the form: {function,{atom,10,m},{atom,10,x},{integer,10,1}}
I know that work has been done (with named funs) on M:F/A, and that 
these should not be concrete, but this asymmetry is not helping anyone?!

Next problem I have is with erl_syntax:subtrees/1 in combination with 
erl_syntax:revert/1. subtrees expect the function and the arity to be 
concrete, while revert will no longer make them concrete. Thus if you 
create subtrees, revert, and then try to manipulate it (for example by 
again looking at the subtrees) things go horribly wrong (crash in 
erl_syntax:implicit_fun_name).

My initial thought was that erl_syntax:implicit_fun_name/1 lacks the 
backward compatibility clause/logic. But since the forms returned by the 
parser are concrete, it could be that erl_syntax:revert_implicit_fun is 
doing the wrong thing instead?! Either way this is causing problems and 
confusion... If we can agree what is the preferred fix I'm happy to 
implement a patch!

Cheers,

Hans


More information about the erlang-bugs mailing list