3 ms·
> In Erlang/Elixir, every function from another module is async by design, and the await is implicit. This statement confuses me. What if I never spawn a pro
by bcrosby95 6y ago
> In Erlang/Elixir, every function from another module is async by design, and the await is implicit.
This statement confuses me. What if I never spawn a process? What if the process I spawn makes function calls into other purely functional modules?
- linkdd 6y agoFunction calls to another module ALWAYS introduce a breakpoint so the BEAM (Erlang VM) can check if the target module is up-to-date, and perform hot code reloading if it isn't. Therefore, every function is interruptible (implicit async), and calls to another module function introduce the breakpoint (implicit await). You always have at least one process, the one running your code. Even if you don't spawn any more processes. And the BEAM still needs to handle signals (like messages, traps, crash, ...) that could be received from another node at any point in time, therefore it needs to be able to interrupt your code, which will be, by design, interruptible. The very nature of Erlang/Elixir is asynchronous by design, even if you don't really see it in the syntax (as it should be, because your concern is the algorithm/data exchanges, not the underlying execution model).