[erlang-questions] examples for erlang with joins

Zvi exta7@REDACTED
Sun Mar 8 13:04:28 CET 2009


Hi Hubert,

nice work. Does it work only inside receive or for any pattern match?
If it's supporting generic pattern matching, I would suggest, rewriting
mochiweb HTML parser, using your join patterns.

http://github.com/tswicegood/mochiweb/blob/a52f350406c69e24cc5f0aceda1d8dfef6a8fdd4/src/mochiweb_html.erl

It has a lot of uggly code like this:

-define(IS_WHITESPACE(C),        
    (C =:= $\s orelse C =:= $\t orelse C =:= $\r orelse C =:= $\n)).

f(C) when IS_WHITESPACE(C) -> ...

using your join patterns you can rewrite it, like:

f(C = ($\s and $\t and $\r and $\n) ) -> ...

I would suggest some better syntax/operator instead of "and" keyword, like:

f(C = ($\s ^ $\t ^ $\r ^ $\n) ) -> ...


Also, I would like to test the parse transform version.

BR,
Zvi


Hubert Plociniczak-3 wrote:
> 
> Hi All,
> 
> I've been working recently on extending Erlang with constructs that allow
> for matching on multiple messages in the mailbox.
> The idea comes from Join-calculus, and its implementation in languages
> like
> Polyphonic C# or JoCaml.
> So, programmers should be able to write for example:
> 
> receive
>   {foo, One} and {bar, Two} when (One > Two) ->
>     expr.....;
>  ....
> end
> 
> And I also added similar behaviour to gen_server.
> 
> The problem now I have, is to actually find a good example to prove that
> such constructs could be useful to have in the language. I have already
> implemented solutions to Santa Claus or Wide Finder problem, but I am
> potentially looking for something bigger, like some already existing
> application, that could be more clear using this syntax. Any ideas?
> 
> Another question relates to the implementation of the extension. I've got
> two versions, one uses standard Erlang and parse_transform and the other
> uses changes I made to the erts. I was wondering if there are any tests
> available for the runtime as there is nothing I can find in the source
> code?
> 
> Thanks,
> hubert
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 

-- 
View this message in context: http://www.nabble.com/examples-for-erlang-with-joins-tp22394129p22397309.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list