[erlang-questions] *current* value?

Gerd Flaig <>
Thu Oct 18 03:16:42 CEST 2007

YC <> writes:

> Basically - one can bind the value by a particular context (I think in
> Erlang process is the basic unit for a context).  The main use is to reduce
> the # of parameters that needs to be explicitly passed in, which obviously
> makes the function impure (although can be more practical).

to the contrary, the function becomes impure if it has side effects,
like e.g. modifying the process dictionary.

The number of parameters passed for the current state is normally
exactly 1. If the state has structure, most of the time records are

% create record with some default values
-record(state, {current_confusion=none, current_answer=42}).

start() ->
    % initial state record is constructed with defaults

server_loop(State) ->
        {get_confused, Confusion} ->
        {set_answer, Answer} ->


        Goodbyte, Gerd.
The last thing one knows in constructing a work is what to put first.
                -- Blaise Pascal

More information about the erlang-questions mailing list