Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

An ability to use {n, l, "something} ! Msg #12

merged 1 commit into from May 24, 2013


None yet
2 participants

doubleyou commented Nov 24, 2011

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:


doubleyou commented Nov 24, 2011

What else I think can be done here:

  1. The entire parse transform can be simplified, but I'm not sure it's necessary.
  2. Personally, I don't like using {n, l, Term} for this case, using just Term would be nicer. However, this will make us to look up at both local and global namespaces, and name clashes won't be acceptable.
  3. Adding another clause to gproc:send/2 seems kind of ugly, but I didn't see a better way to handle classic message sending operations.
  4. Probably, need to update header of gproc_pt.erl

uwiger commented Nov 29, 2011


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:


parse_transform(Forms, _Options) ->

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) ->

which is very stable even in the face of grammar changes, and therefore works with just about any version of erlang.

@uwiger uwiger merged commit e76c5f3 into uwiger:master May 24, 2013


uwiger commented May 24, 2013

I finally merged this. Sorry about the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment