Prakash Wagle
Prakash Wagle

Reputation: 23

Whats the relation between a module and a process in Erlang

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

Upvotes: 2

Views: 70

Answers (1)

7stud
7stud

Reputation: 48649

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 ?

  1. There aren't two processes unless you start two processes.

  2. Message passing between processes is done by calling send/2 or using the operator !. Messages are read inside a process using a receive clause.

Upvotes: 2

Related Questions