I am new to Erlang trying to understand what's the relation of a module and a process in Erlang. Dose each module spun up a new process in BEAM ? When we call a function from another module is there message passing been done between two process ?
I tried to search go through Erlang docs, while working on a existing Erlang code
Functions execute inside processes, whether they are defined in a module or not.
Dose each module spun up a new process in BEAM ?
Nope. You can define 50 modules and the functions therein can all execute in a single process. Modules are more like namespaces.
When we call a function from another module is there message passing been done between two process ?
There aren't two processes unless you start two processes.
Message passing between processes is done by calling send/2
or using the operator !
. Messages are read inside a process using a receive clause
.