Closed doubleyou closed 11 years ago
What else I think can be done here:
Hi,
I am not particularly fond of erl_id_trans.erl, since it needs to be ported every time the language grammar changes a bit (which, admittedly, is not that often).
One can either use parse_trans or syntax_tools, or write something along the lines of:
-module(xform).
-export([parse_transform/2]).
parse_transform(Forms, _Options) ->
do_transform(Forms).
do_transform([{op, L, '!', Lhs, Rhs} = F|Fs]) ->
[NewLhs] = do_transform([Lhs]),
[NewRhs] = do_transform([Rhs]),
[{call, L, {remote, L, {atom, L, gproc}, {atom, L, send}},
[NewLhs, NewRhs]} | do_transform(Fs)];
do_transform([]) ->
[];
do_transform([F|Fs]) when is_tuple(F) ->
[list_to_tuple(do_transform(tuple_to_list(F))) | do_transform(Fs)];
do_transform([F|Fs]) ->
[do_transform(F) | do_transform(Fs)];
do_transform(F) ->
F.
which is very stable even in the face of grammar changes, and therefore works with just about any version of erlang.
I finally merged this. Sorry about the delay.
Hi, Ulf. Since you thought that the idea is worth a try, I decided to make a pull request instead :)
The implementation I've mentioned at the issues was incomplete, so don't mind it. The code of parse transform is completely stolen from erl_id_trans.erl, I've just added 2 lines: https://github.com/doubleyou/gproc/blob/master/src/gproc_pt.erl#L450