[racket] Delimited continuations and parameters

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Mon May 14 21:50:01 EDT 2012

On 2012-05-14 19:00:49 -0600, Matthew Flatt wrote:
> In other words, every `parameterize' uses the same continuation mark,
> so that `(parameterize ([r 10]) ...)' associates the parameterization
> continuation mark with a single record that maps `r' to 10, `p' to 1,
> etc. The entire record is carried by the delimited continuation.

Thanks Matthew and Ryan, that clears it up. OTOH, it does look like a
straightforward translation to continuation marks (or using
unstable/markparam as Ryan pointed out) doesn't get the 12 result
either.

For example:

  #lang racket
  
  (require racket/control
           unstable/markparam)
  
  (define p (mark-parameter))
  (define r (mark-parameter))
  
  ((λ (f)
     (mark-parameterize ([p 2])
       (mark-parameterize ([r 20])
         (f 0))))
   (mark-parameterize ([p 1])
     (reset
      (mark-parameterize ([r 10])
        ((λ (x) (+ (mark-parameter-first p)
                   (mark-parameter-first r)))
         (shift f f))))))

Will produce an error
+: expects type <number> as 1st argument, given: #f; other arguments were: 10

> In the ICFP'07 paper on delimited continuations in Racket, we wrote (at
> the end of section 5) that we'd probably change `parameterize', but
> we've never gotten around to that change. Meanwhile, raw continuation
> marks (as modeled directly in that paper) essentially match the
> dynamic-binding form of Kiselyov et al.

The raw continuation mark version gives essentially the same error as
above, maybe because call/cc and call/comp restore the marks to what was
present at capture time, which doesn't include the `p` mark?

Cheers,
Asumu

Posted on the users mailing list.