It seems that there's a disagreement in how a delimited continuation
captures dynamic environment, between Racket and srfi-226.

Suppose the following code:

```
(define (print . xs) (for-each display xs) (newline))

(define m (make-parameter 0))

(define c #f)

(define (foo)
  (parameterize ((m 1))
    (reset
     (print 'a: (m))
     (shift k (print 'b: (m)) (set! c k))
     (print 'c: (m)))))

(define (bar)
  (parameterize ((m 2))
    (c #f)))
```

With srfi-226 (using reset/shift as given in the srfi) reference
implementation on Chez, I get this:

```
> (run foo)
a:1
b:1
> (run bar)
c:1
```

With Racket racket/control, I get this:

```
> (foo)
a:1
b:1
> (bar)
c:2
```

I'm switching Gauche's internals to srfi-226 based model, and I noticed the
difference---the current released version of Gauche (relying on
dynamic-wind to handle parameterization) works like Racket, while the
srfi-226 based version (using dynamic env chain to keep parameters) works
like srfi-226 reference implementation.

I think srfi-226 behavior is more consistent (when the delimited
continuation is invoked, it restores the dynamic environment of the
continuation of reset), but is there a plausible explanation of Racket
behavior?

This difference actually caused a compatibility problem of an existing
application so I want to understand it fully.

Reply via email to