[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tail recursion (was Re: a (revised) draft of R5RS)
From: Kent Pitman <kmp@harlequin.com>
Subject: tail recursion (was Re: a (revised) draft of R5RS)
Date: Tue, 27 May 97 16:51:40 EDT
I wrote:
> tricky cases. For example:
>
> (call-with-input-file file f)
>
> Intuitively the call to f will not be tail-recursive,
Kent answers:
> I don't agree. Of course the call will be tail recursive. FROM ITS
> POINT OF CALL, which is not the caller of CALL-WITH-INPUT-FILE. [ ... ]
Nobody knows that without additional information (such as seeing the
source code for call-with-input-file). That was my point.
And in most implementations of Scheme I expect the loop
(define (loop) (call-with-input-file some-file (lambda (p) (loop))))
(loop)
to run either out of file handles or out of memory. This is what I
mean by "intuitively". The implementation must jump through quite a
few hoops in order to make the above not run out of resources (but it
could be done as I outlined before).
-Matthias