[erlang-questions] call by value
Robert Raschke
rtrlists@REDACTED
Thu May 19 18:14:49 CEST 2011
On Thu, May 19, 2011 at 4:50 PM, Martin Dimitrov <mrtndimitrov@REDACTED>wrote:
> On 5/19/2011 6:43 PM, Daniel Dormont wrote:
> > In my experience with other languages, the difference between
> call-by-value and call-by-reference is not generally understood to depend on
> whether the data in memory is physically copied or not. That's really an
> implementation detail.
> On first read I can't think of an example where the implementation is
> not actually copying the value.
> > Rather, the difference is whether the argument "itself" is passed as
> opposed to its value.
> >
> Would then in Erlang be more appropriate to say that the argument
> "itself" is being passed, thus saying call-by-reference?
>
>
You have to remember that in Erlang there are only values. You don't have
references. What you have is names for values, but that's all it is, a name
for a value, just like you use the word "one" to denote the value of the
numeral 1.
The great thing about having only values, is that you don't have to make
copies in memory, because there's no way to destroy or update them.
You can emulate references by using state carrying data structures. Some
assembly required.
Robby
PS And yes, you can delve into deeper aspects, where the "value" metaphor
breaks down a bit. But usually you need to have a reasonably good reason for
doing that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110519/40505c7d/attachment.htm>
More information about the erlang-questions
mailing list