[erlang-questions] Is the function call always pass by value?

饕餮 249505968@REDACTED
Sat Mar 9 10:16:15 CET 2013


I have do a test about the function call.
There are some strange thing happen when I use function call to pass a tuple. 
The runtime won't change whatever the tuple scale size change(still smaller than 10k atom in it).
So I wonder if the function call always pass value?




And in I my project there is a efficiency bottleneck.
There is some function loop with passing some large record.
simply like this
%=============================
dot_write_func_dup(N) ->
	X = #test{},
	statistics(runtime),
	dot_func_dup(N,X),
	{_,TotalRunTime}=statistics(runtime),
	io:format("totalruntime:~w~n",[TotalRunTime]).
%=============================
dot_func_dup(N,X) when N > 0 ->
	I = X#test{r500 = n},
	J = I#test{r501 = m},
	dot_func_dup(N -1 ,X);
dot_func_dup(0,X) ->
	I = X#test{r500 = n},
	J = I#test{r501 = m}.

%=============================It seems very slow with the loop.
And we attempt to change the record loop to process dictionary.
It's worthy to change it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130309/bc0c569e/attachment.htm>


More information about the erlang-questions mailing list