[erlang-questions] Parse-transforming !! to a function call

Robert Virding rvirding@REDACTED
Thu Aug 16 00:24:43 CEST 2007


There is one small problem with this fix, as you have not modified the
tokeniser it will allow you to write things like:

test1() ->
    A !      ! B.

test2() ->
    A !

    ! B.

Which does look a little strange. :-)

Robert

On 15/08/07, Joe Armstrong <erlang@REDACTED> wrote:
>
> yes indeed very easy !! needs a one line addition to erl_parse.yrl
>
>
> Find erl_parse.yrl (in stdlib/src)
>
> Look for a line  like this:
>
>   expr_100 -> expr_150 '!' expr_100 : mkop('$1', '$2', '$3').
>
> Then add the following
>
> expr_100 -> expr_150 '!' '!' expr_100: {call, line('$1'),{atom,
> line('$1'), rpc},['$1', '$4']}.
>
> This turns all calls A !! B into rpc(A, B)
>
> Build a new parser
>
> > erlc erl_parse.yrl
> > erlc erl_parse.erl
>
> test with (for example)
>
> -module(bang).
>
> -compile(export_all).
>
> test1() ->
>     a !! b.
>
> rpc(A, B) ->
>     {hello, A, B}.
>
> $erl
> > c(bang).
> > bang:test1()
> {hello, a,b}
>
> This way you can redefine !! as you please by using an appropriate
> -import(xyz, [rpc/2]) in your code
>
> *remember* !! is addictive - so don't forget to remove !! from programs
> you
> distribute, since you need a non-standard parser to parse the sources.
>
> (I guess we need a -use_parser(Mod) annotation in the code :-)
>
> Question (to Joel) can't the entire Obj c interface be made dynamic using
> obj_sendMsg???
>
> The call [obj with:i str:@"abc"]
>
> can be built dynamically using something like
>
> int i;
> NSString s;
> i = 1234;
> s = @"hello"
> obj_sendMsg(obj, NSSelectorFromString(@"with:str:", &i, s)
>
> and the type signature can be found introspectively - I think this is
> how Fscript does it
>
> Cheers
>
> /Joe
>
>
>
>
>
> On 8/12/07, Ulf Wiger <ulf@REDACTED> wrote:
> > This looks like Joe's "bang-bang" notation.
> > Joe made a small change to the parser to make this possible.
> > He first wrote about it in http://www.sics.se/~joe/nerl.html,
> > I think.
> >
> > BR,
> > Ulf W
> >
> > 2007/8/12, Joel Reymont <joelr1@REDACTED>:
> > > Folks,
> > >
> > > Suppose I wanted !! to send a synchronous message via a function
> > > call. How would I write a parse transform to do it?
> > >
> > > I would like x !! y to be transformed into mod:func(x, y). Is this
> > > possible?
> > >
> > >         Thanks in advance, Joel
> > >
> > > --
> > > http://wagerlabs.com
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > erlang-questions mailing list
> > > erlang-questions@REDACTED
> > > http://www.erlang.org/mailman/listinfo/erlang-questions
> > >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070816/3651bc4f/attachment.htm>


More information about the erlang-questions mailing list