Subject: Re: New to Common Lisp; range function
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 27 Aug 2007 21:06:20 -0500
Newsgroups: comp.lang.lisp
Message-ID: <SpSdnWlcy86BHk7bnZ2dnUVZ_tajnZ2d@speakeasy.net>
Klaus Schilling  <schilling.klaus@web.de> wrote:
+---------------
| > There's nothing in the CL stantard per se, but the function you
| > describe would, in CL, commonly be done using LOOP to avoid possible
| > stack overflow for *large* values of (- END START):
| 
| would an iteration with "do" or a tail recursive formulation work?
+---------------

As others have said, tail recursion [or more generally,
tail call optimization] is not required in Common Lisp,
and is not possible in the general case in the presence of
dynamic variable bindings or exception handler bindings.[1]
Thus, lacking "safe-for-space" tail call optimization,
one can run into the stack overflow issue I mentioned.


-Rob

[1] Yes, yes, I know there have been some exotic ways
    proposed to handle tail call optimization in the
    presence of dynamic variable bindings, but I don't
    know of any implementation that does so. And even
    then exception handler bindings would mess things up.

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607