[erlang-questions] Parameterized module idioms

Vlad Dumitrescu <>
Tue Apr 20 21:04:43 CEST 2010

On Tue, Apr 20, 2010 at 17:15, Mazen Harake
<> wrote:
> If you create a new "instance" of a module with a parameter, then you need
> to have that "instance variable" around to call it right? So you need to
> keep it somewhere... as a state.
> So in any case you need to keep a state, in other words you haven't achieved
> anything (except perhaps making your code more obfuscated).
> So _why_ is it ["of course"] "easier to use module parameters instead of
> passing closures or state around"?


If you send state around the functional way, it has to be a parameter
to all the functions that use some part of that state. If the state
data changes, it may be needed to update all these places (if the
state representation wasn't flexible enough).

If the state is globally accessible, you just use the appropriate
variable where it is needed.


More information about the erlang-questions mailing list