Newsgroups: comp.lang.scheme
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!jensen.utah.edu!carr
From: carr%jensen.utah.edu@cs.utah.edu (Harold Carr)
Subject: bindings captured by continuations
Date: 19 Apr 91 10:52:44 MDT
Message-ID: <1991Apr19.105244.27822@hellgate.utah.edu>
Organization: CSS

My understanding of a continuation is that is should capture the data
and control at the point of call/cc and bind that to the given
lambda's parameter.  It is clear that any variables within the lambda
given to call/cc but bound outside are closed and therefore any
changes to the values of those bindings by others sharing the closed
variables are visible.

However, it seems to me, that bindings/values created before the
call/cc and captured by it, should not see any side effects done
*after* the continuation point when that continuation is used again.
An example should make this clear.

In elk:


(define cont1)

(define (cmaker)
  (let ((count 0))
    (if (= count 0)
      (call-with-current-continuation
       (lambda (cont)
	 (set! cont1 cont))))
    (set! count (+ count 1))
    (newline)
    (display count)))

(cmaker)

==> 1

(cont1 'dummy)

==> 2

(cont1 'dummy)

++> 3

and so on


Is this the correct behavior?  If not, what should be.

The call to CMAKER should definitely print 1, but it seems that the
first call to CONT1 should also print 1.

References to applicable papers would be appreciated.

Thanks,
Harold


