[erlang-questions] Semantics of send

Richard O'Keefe <>
Thu Apr 29 00:48:18 CEST 2010


On Apr 28, 2010, at 11:31 PM, Johan Montelius wrote:

>
>
> What is the semantics of send?  In the following example:
>
> to_a_or_to_ab_or_to_none(A, B) ->
> 	A ! foo,
> 	B ! bar,
> 	crash().
>
> If B receives bar is it then so that A receives foo?

Consider the following scenario:
    (1) The message for A is scheduled for delivery in the VM
    (2) The message for B is scheduled for delivery in the VM
    (3) The sender crashes.
    (4) The VM puts the message for B on a wire, which happens
        to be routed through a microwave link.
    (5) The VM puts the message for A on another wire, which
        happens to be routed through an RFC1149 [%] link.
    (6) The message for B arrives.
    (7) The RFC1149 carrier is eaten by a sparrowhawk.

[%] Internet Protocol over Avian Carriers (pigeons).  According
to the Wikipedia, it has been implemented.  The Norwegian version,
where the avian carriers carried some sort of memory chip, actually
beat ADSL for throughput, albeit with terrible latency.

>
> And where is the behavior stated?

Both the "Erlang Programming" book and the "Programming Erlang" book
explain it, it's in the documentation, ...
>
> Is it guaranteed by the Erlang implementation in a distributed  
> setting?

As explained above, how _could_ it be?
>
> If the sender crashes, is disconnected ...

Once a process has launched a message, there is no further
relationship whatsoever between that process and that message,
unless the programmer explicitly placed the process's PID as
part of the message data.

You could replace "processes" by "people" and "messages" by
"snail-mail letters", and nothing would change.  Message
transport between nodes is inherently unreliable.  Message
transport _within_ a node is normally taken as reliable,
but even then, it's possible for process A itself to die
before all messages sent to it are delivered.
>



More information about the erlang-questions mailing list