Why is the word "cast" used to handle async message in a GenServer?

128 views Asked by At

Why, in Erlang/Elixir, is the asynchronous GenServer handler named with handle_cast? The handle_ part is obvious, but why the word cast?

The only thing I can think of is that it is akin to just throwing something out there (as in casting a net) vs calling out for something and waiting for a reply.

1

There are 1 answers

1
ryanwinchester On BEST ANSWER

I think you answered the question yourself, already.

The only thing I can think of is that it is akin to just throwing something out there (as in casting a net) vs calling out for something and waiting for a reply.

However, apart from asking the erlang creators, we can only speculate.

Cast: to cause to move or send forth by throwing

Basically, you're tossing a message to the GenServer, not expecting something in response.

Call: to make a request or demand

I think this is something that expects a response. If you call to someone you expect them to answer.