[erlang-questions] call by value

Ulf Wiger <>
Thu May 19 17:41:23 CEST 2011

You should ignore the issue of copying. Essentially, Erlang can be viewed as using copy-on-write semantics.

The key is whether the expression is evaluated or not (it is) before the function is called, and also whether the called function can modify the input parameters (it can't)*.

* Unless you use unholy functions like hipe_bifs:bytearray_update/3, which of course you don't. ;-)

Ulf W

On 19 May 2011, at 17:36, Martin Dimitrov wrote:

> Hi,
> How will we have to interpret this citation from "Erlang Programming" by
> Francesco Cesarini and Simon Thompson (page 30):
> "All calls with variables in Erlang are call by value: all arguments to
> a function call are evaluated before the body of the function is
> evaluated. The concept of call by reference does not exist, ..."
> I know that variables are not copied when making a function call and are
> copied when sending messages to processes. So why do the authors say all
> calls are call by value? Aren't the function calls actually call by
> reference?
> Regards,
> Martin
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

Ulf Wiger, CTO, Erlang Solutions, Ltd.

More information about the erlang-questions mailing list