Question about receive-block in IEx

Hello World,

I am new to Elixir.

I am learning from this Elixir on my Ubuntu host:

$ elixir -v
Erlang/OTP 22 [erts-10.4.3] [source] [64-bit] [smp:4:4]
[ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.9.0 (compiled with Erlang/OTP 21)
$

I am confused by the behavior of a receive-block I wrote.

I typed some syntax into iex:

self()
# #PID<0.103.0>
receive do int1 -> int1 end

At that point iex “hung” which makes sense to me because the
receive-block is waiting for a message.
And that behavior matches my understanding of h(receive).

I started another iex session and sent a message to the receive-block:

apid = pid(0,103,0)
send apid, 55

I expected the receive-block to accept the message and then return
the iex-prompt to me.

But, it remained “hung”.

Q: Should I expect the receive-block to accept the message and then return
the iex-prompt to me?

Welcome to the forum!

No.

Each iex prompt is essentially a separate (disconnected) node.

Chapter 16. Nodes—The Key to Distributing Services of Programming Elixir 1.6
shows you how to get them to talk to one another (Node.connect/1).

3 Likes