Subject: Re: It's A Big Language Survey
From: (Rob Warnock)
Date: Wed, 29 Apr 2009 20:05:29 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
gugamilare  <> wrote:
| chthon <> wrote:
| > If I program in Scheme then it is almost natural to use tail
| > recursion, while in Common Lisp, generally that can not be the case,
| > since this is implementation dependent. So I use LOOP fairly often.
| People keep saying that tail recursion in CL is implementation
| dependent, but the only implementation that I tested that doesn't have
| tail call optimization is ECL, and I expect that to be changed. Even
| Clisp, which is not optimized, has this optimization if you compile
| the function.

Careful! What you say is true *only* in the absence of live bindings
for dynamic variables or live dynamic contexts such as UNWIND-PROTECT,
Even CL implementations which routinely do TCO for "simple" tail calls
generally cannot do TCO across such contours!! Note that the non-TCO'able
case could be as simple as this:

    > (defun foo (*standard-output*)
        (format t "This was *not* a tail call of FORMAT!!"))

    > (with-output-to-string (s)
	(foo s))

    "This was *not* a tail call of FORMAT!!"


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607