Question

The more I study/program Erlang, the more I realize I have to learn. But here I'd like to confirm or dispel an assumption I've been making:

Assume two modules. One I package as a library; the other I package as a server. Question: Why the distinction?

Assumption: Functions in the second module either need to maintain state isolated from the rest of the system or run concurrently with other functions.

Is this true and the only two reasons for packaging a module as a server?

Thanks,

LRP

Was it helpful?

Solution

In general you are right, a module may just be a collection of functions. It stores no state and has no persistent processes. Or it can be something that maintains state in the form of one or more processes. This would normally be done with a gen_server, gen_fsm or gen_event depending on what you want to use it for

(Of course you can maintain state in mnesia/ets as well)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top