At Thu, 19 Aug 2010 19:04:49 +0200, Bas Steunebrink wrote: > Hi all, > > From what I understand about call/cc, when a saved continuation is > invoked, the current continuation should be discarded. So I expected the > following program to just print `stop?' once; however, it doesn't stop. > > > Welcome to DrScheme, version 4.2.4 [3m]. > Language: Pretty Big; memory limit: 128 megabytes. > > (define stop > (let ((k (call-with-current-continuation (lambda (k) k)))) > (lambda () > (display "stop?\n") > (k k)))) > > (begin (stop) (stop) 42) > stop? > stop? > 42 > > > > > So is this an error in my understanding of call/cc or in DrScheme?
You need two more pieces of information: * When `begin' appears in a top-level position, its expressions are spliced into the top level. * Every top-level expression is evaluated inside a "prompt" that delimits continuation capture and invocation. So, each call to `stop' discards only the continuation up to the prompt that wraps the call to `stop'. _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users