question about parse-transform

37 views
Skip to first unread message

yoast

unread,
Apr 7, 2013, 9:52:29 AM4/7/13
to chica...@googlegroups.com
in this blog   http://blogtrader.net/blog/recbird_an_erlang_dynamic_record#    ,
caoyuan gives a parse-transform to make a better erlang record syntax, 
i.e., using R.a.b.c and R.a.b.c=Sth.
 
it may compiles in the early versions of erlang, but failed in recent versions.
AFAIK, now the input to a P-T should be well-formed erlang AST, obviously,
a.b.c cannot parse.

But CB used a lot of compiler magic, may source files cannot parse without P-T.
So i think there is some way to work around the recbird P-T so that it can work
with new erlang version.

Can anyone(Evan? :-) give me some help? 
There seems to be no good tutorial on this "secret" topic, to show newbie a 
step by step way to master this nuclear weapon.

thanks in advance~


Evan Miller

unread,
Apr 7, 2013, 10:45:44 AM4/7/13
to ChicagoBoss
Hi yoast,

I suspect one of the following is the culprit:

1. Erlang's syntax changed slightly with R16, disallowing unquoted
atoms with dots in them (e.g. foo.bar.baz ). This was partly a result
of removing packages from Erlang. It could be that the parse transform
relied on this atom syntax.

2. The internal representation of Erlang AST also changed slightly,
but I've been unable to find any documentation on it. The issue that
has bitten me is that the atom 'func' was replaced by 'function' in a
few places. This might cause the parse transform to fail -- but that
assumes the Erlang code was correctly parsed (which if #1 holds, it
was not).

Parse transforms are indeed a dark corner of Erlang... probably more
P-T code out there is broken than is functioning. But they're fun,
aren't they?

Evan
> --
> You received this message because you are subscribed to the Google Groups
> "ChicagoBoss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to chicagoboss...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Evan Miller
http://www.evanmiller.org/

yoast

unread,
Apr 7, 2013, 9:17:39 PM4/7/13
to chica...@googlegroups.com
Thanks Evan!~
It seems someone likes the power of AST manipulation, while others worry about the abuse of it (or intentionally try to hide the power?).
I personally like the magic, and maybe Ulf Wiger knows all the internals...

在 2013年4月7日星期日UTC+8下午9时52分29秒,yoast写道:

Graeme Defty

unread,
Feb 14, 2014, 5:25:51 PM2/14/14
to chica...@googlegroups.com
Hi guys,

I have a suspicion that I have fallen foul of #2 in Evan's mail here.

Having upgraded to R16 (thankfully in a duplicate machine!) my app fails to compile with the following . . .

(ege@testhost)1> 05:10:06.972 [error] gen_server boss_web terminated with reason: no match of right hand value {error,[{"/home/graeme/projects/egolf/dev/tournaments/src/controller/egolf_comp_controller.erl",[{{265,25},erl_lint,{undefined_function,{is_integer,2}}}]}]} in boss_load:load_all_modules/3 line 29
05:10:07.060 [error] CRASH REPORT Process boss_web with 0 neighbours exited with reason: no match of right hand value {error,[{"/home/graeme/projects/egolf/dev/tournaments/src/controller/egolf_comp_controller.erl",[{{265,25},erl_lint,{undefined_function,{is_integer,2}}}]}]} in boss_load:load_all_modules/3 line 29 in gen_server:terminate/6 line 744
05:10:07.149 [error] Supervisor boss_sup had child boss_web_controller started with boss_web_controller:start_link([{ip,"0.0.0.0"},{port,8001}]) at <0.67.0> exit with reason no match of right hand value {error,[{"/home/graeme/projects/egolf/dev/tournaments/src/controller/egolf_comp_controller.erl",[{{265,25},erl_lint,{undefined_function,{is_integer,2}}}]}]} in boss_load:load_all_modules/3 line 29 in context child_terminated
    !
   Etc
    !

Now "is_integer(23)" works just fine from the shell, so I am suspecting the failure to compile is related to the chance in the internal representation, since I m passing "fun is_integer/1" to lists:filter.

Has there been some further discussion on this that I missed?  (I am on CB 0.8.9)

Any help would be greatly appreciated.

Thanks

g



Reply all
Reply to author
Forward
0 new messages