Summary: E / Erlang integration

Michael FIG <>
Mon Jun 19 20:41:01 CEST 2006

Sorry for the long delay... I somehow missed your e-mail.

The examples I gave depended on providing the same semantics as E.  Basically, the "send" is an eventual send that doesn't block the calling process.  The "promise_case" or whatever function is not supposed to block the caller either, which is why it takes all those funs.  They are separate functions because the caller may make several sends before issuing the "promise_case" to collect the results.

With both of these functions non-blocking, there is a guarantee that deadlock is impossible.  That's the main property of E programs that I'd like to achieve in this library.

Does that explain things a bit better?

Michael FIG <>, PMP

----- Original Message -----
From: Ulf Wiger (AL/EAB) <>
To: Michael FIG <>, , Discussion of E and other capability languages <>
Sent: Monday, June 12, 2006 3:12:33 AM GMT-0200
Subject: RE: Summary: E / Erlang integration

I think that even without sugar, it can be cleaned up a little:

%% @spec send(To, Request, Timeout, MatchFun) -> Result
%% @throws timeout

try e:send(RaceTrack, getPolePositionCar, 3000,
           fun(N) when N ==FarPolePositionCar ->
                io:format("My car is in pole position~n"),
              (_) -> no_match
           end) of 
   Result -> Result
      throw:timeout -> ...

I'd rename the function to something other than send(), since the
asynchronous send-and-pray function in erlang is erlang:send(Dest, Msg).

I see no reason to create funs for anything but a filter function. This
fun should be passed to another process, and the return values passed
back as regular messages. Compare with gen_server call.

Ulf W

Michael FIG wrote:
> I retract my original suggestion of developing 
> special syntax for E message sending (the !< part), since 
> that can easily be accomplished by a library function 
> "Promise = e:send(CryptoCap, Message)".  However, the 
> when/catch construct of E would be clunky to use without some 
> syntactic sugar.
> With sugar:
>     promise_case e:send(RaceTrack, getPolePositionCar) of
>         FarPolePositionCar ->
>             io:format("My car is in pole position~n");
>         after 3000 ->
>             io:format("Timed out~n")
>         catch E ->
>             ok;
>     end.
> without sugar:
>     e:pcase(e:send(RaceTrack, getPolePositionCar),
>             fun (SomeFreshName) ->
>                  case SomeFreshName of
>                     FarPolePositionCar ->
>                         io:format("My car is in pole position~n"),
>                         matched;
>                     _ ->
>                         notmatched
>                  end
>             end,
>             3000, fun () -> io:format("Timed out~n"),
>             fun (E) -> ok end).

MarkeTel Systems has made every effort to ensure this message is
virus-free.  Our mail server uses multiple virus scanners to
provide maximum protection. 

More information about the erlang-questions mailing list