HadesLang Doc
Search…
Message passing
As Hades implements the actor model, it also needs some way for concurrency between these actors.
The way I thought to be most elegant was Erlang/Elixir-style message passing. To do so, Hades provides a built-in method to send (called send) and a block to receive (receive) messages.
send takes a pid and any value to send something to a process. receive works similar to a match block in that it can also match on object/list level, but the supplied argument to receive actually tells Hades to put the received data (no matter what it is) in a variable with the name of whatever the name of the supplied argument is.
1
with console from std:io
2
3
var p = spawn({_ =>
4
var data
5
receive(m)
6
_ => data = m
7
end
8
console.out(data)
9
})
10
11
send(p, "Hello")
Copied!
Last modified 2yr ago
Copy link