Proper Tail Recursion vs Iteration
It is natural to wonder whether special looping syntaxes might be more efficient (by some constant factor) than proper tail recursion.
That depends on the implementation.
In some properly tail recursive implementations of Scheme,
for example, do
loops are faster than the
equivalent loop expressed using tail recursion.
In most implementations of Scheme, the special syntaxes macro-expand into equivalent recursions, so the special syntaxes are no faster than using tail recursion.
Whether proper tail recursion is as fast as the
while
and for
loops of
languages like C and Java also depends on the
implementation.
In one implementation of Scheme, on one target machine,
((lambda (f) (f f)) (lambda (f) (f f)))
compiles into a branch instruction that branches to itself. It is impossible for special looping syntaxes to improve upon the efficiency of proper tail recursion as implemented by that compiler.