[erlang-questions] Question about implementation
Richard O'Keefe
ok@REDACTED
Mon Sep 10 23:53:41 CEST 2012
On 11/09/2012, at 2:27 AM, Max Lapshin wrote:
> Will here whole #state{} be deep-copied with new Counter +1 field,
No it will be *shallow*-copied. You get a new #state term, but
any fields that are not changed will not themselves be copied.
> or
> it is possible to guess, that here optimization is possible and just
> "edit" counter field in existing tuple?
>
> Is it possible to understand by erlang source code, that State is no
> longer referenced anywhere to avod large allocation and free?
For the special case of states passed around loops of private functions
it ought to be possible to infer that a function argument is not shared
but for exported functions it is not possible because it depends on the
callers.
More information about the erlang-questions
mailing list