[plt-scheme] call/cc and space

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Feb 7 13:46:53 EST 2006

I've committed an update to v301.5 in SVN to fix these problems ---
even the last example, which was in the "known bugs" list for about a
decade.

The repair is related to recent changes in the representation of
continuations. (In the original v301.5, I didn't get it right in a
relevant case: captured continuations that are the same except for
marks on the most recent frame.)

Matthew

At Wed, 15 Jun 2005 16:44:49 -0400, David Van Horn wrote:
> The recent mention of space safety made me revisit R5RS.  Is my understanding 
> correct in that the following should use a bounded amount of memory?
> 
> (let loop () (call/cc (lambda (k) (loop))))
> 
> R5RS requires call/cc to apply it's argument in a tail position, and the call 
> to loop is in a tail position within that procedure.  For the same reason, the 
> following should run in constant space (and does):
> 
> (let loop () (apply loop '()))
> 
> The callcc example grows in MzScheme, although not in Petite Chez.  It also 
> doesn't seem to be an instance of this known problem:
> 
> (let loop ([x 0]) (call/cc loop))
> 
> The problem here being that although "x" isn't referenced in the body of the 
> loop, it's still captured by the continuation.
> 
> David


Posted on the users mailing list.