[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
call/cc and proper tail recursion
Date: Fri, 20 Nov 92 16:53:25 EST
From: Marc Feeley <feeley@iro.umontreal.ca>
While I'm on the subject, one of the things that bugs me about the
definition of call/cc is that these two definitions are not
equivalent:
(define (foo) (call/cc (lambda (k) (f x))))
(define (foo) (call/cc (lambda (k) (k (f x)))))
Although the value returned by foo is the same for both definitions,
the second form may run out of space when the first doesn't (for
example if f tail-recurses into foo).
This isn't fundamentally different from
(define (foo)
(let ((k (lambda (y) y)))
(k (f x))))
in which a call to foo doesn't reduce to a call to f. There's nothing
special about call-with-current-continuation in this regard; it's a
question of whether the language is normal or applicative order.