On Thu, Jan 24, 2008 at 09:43:23AM -0800, Tom Gal wrote:

Also recursion just uses the system stack as a data structure, so iteration
typically is not only faster in implementation due to less pushing and
popping of stack frames (of course if you use a smarter data structure) on
the runtime stack, but can typically use less memory because of all of the
unnecessary overhead of a function call tree managed in an ultra-generic
fashion by your computer.

The important point is that Scheme compilers are _required_ to implement
certain kinds of recursion (tail calls) as jumps.  This is important,
because recursion is the only way to express iteration in Scheme.

Tail recursive functions in Scheme do not use stack frames and are not less
efficient than loops in other languages.

What is important is being able to understand what tail calls are, because
non-tail calls do require stack space.

David

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to