This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: searching an explanation: call/cc and 'do' strangeness


On 15 Apr 1999, Gary Houston wrote:

> <...citation deleted...>
> 
> It's the usage of call/cc.  It's capturing the current bindings,
> but the values in the bindings can be changed within the continuation
> loop.
> 

Thank you for your answer.  Regrettably, we are not quite certain what the
lesson of your answer is.

Do we have to avoid using the call/cc for all kind of coroutine-style
iterations in datastructures?  Or is there a way to encapsulate the usage
of call/cc so that we can trust code outside the encapsulation to behave
predictably?  (OK, I guess the behaviour we have observed *is*
predictable, somehow, but only within a global scope of the entire
program).

				--peder chr.
> consider:
> 
> (define cont #f)
> (let ((i 0))
>   (let loop ()
>     (display i)
>     (newline)
>     (if cont
> 	(cont #f))
>     (call-with-current-continuation (lambda (c)
> 				      (set! cont c)))
>     (set! i (+ i 1))
>     (loop)))
>  
> 
> (define cont #f)
> (let loop ((i 0))
>   (display i)
>   (newline)
>   (if cont
>       (cont #f))
>   (call-with-current-continuation (lambda (c)
> 				    (set! cont c)))
>   (loop (+ i 0)))
> 

Peder Chr. Nørgaard                   System Developer, M. Sc.
Telebit Communications A/S            tel: +45 86 28 81 77 - 49
Fabrikvej 11                          fax: +45 86 28 81 86
DK-8260 Viby J   Denmark              e-mail: pcn@tbit.dk