Some basic Messaging patterns, howto in Web-Prolog?

First, let me point out that Erlang’s receive primitive is often referred to as a selective receive. (Googling for ’ “selective receive” Erlang’ finds almost 2000 hits.)

I see at least three issues with your proposal:

  1. What about guards? Where do they come in? If you’re serious here, you owe me an implementation of important/1 using your message_select/2, i.e. what we discussed in this topic.

  2. And in what way is your proposal any better than using thread_get_message/1, like so?:

    query(Query, Self, Parent) :-
        call_cleanup(Query, Det=true),
        (   var(Det)
        ->  Parent ! success(Self, Query, true),
            thread_get_message(Message),
            (Message==next -> fail;
             Message==stop -> Parent ! stopped(Self))
        ;   Parent ! success(Self, Query, false)
        ).
  1. And what happens if someone sends a message foo to the process, does is crash? Or is the message deferred? Using thread_get_message/1 as above would not defer foo, but since the whole if-then fails, it would have the same effect as sending next. (There are ways around that but you have to change the form of your messages.) What about your solution?