To send a message to another Erlang process you should use
! operator. You write it like that: a process identifier, an exclamation mark, and then the message itself:
Proc = spawn(world, loop), % ... Proc ! "Hello".
To receive a message you use
loop() -> receive Message -> io:format("Message received: ~s~n", [Messsage]) end.
You can specify a timeout and handle the case when no messages were received within a given period of time:
loop() -> receive Message -> io:format("Message received: ~s~n", [Messsage]), after 5000 -> io:format("5 seconds have passed, but no messages have been received~n") end.
Now we can implement an event loop on top of messaging.