[erlang-questions] Tail Call Optimization and Parameter Ordering

Bjorn Gustavsson bjorn@REDACTED
Tue Nov 6 14:33:11 CET 2007


"David Mercer" <dmercer@REDACTED> writes:

> 
> If, on the other hand, the object is at the beginning of the
> parameter list, it will always be in the same position and will cause less
> stack manipulation.  Granted, this optimization only occurs in the case of
> tail calls, but surely this is a good habit to be in for that case when the
> tail call optimization can be used.

Arguments are passed in (virtual machine) registers, not on the stack. The same
optimization is done for any type of call, tail-recursive or body-recursive;
if a value happens to be in the right register, no extra move instructions will
be generated.

/Bjorn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list