[racket] Continuation marks

From: John Clements (clements at brinckerhoff.org)
Date: Fri Sep 5 18:04:12 EDT 2014

On Sep 5, 2014, at 2:24 PM, Gustavo Massaccesi <gustavo at oma.org.ar> wrote:

> I'm trying to add a continuation mark inside a function, but I want
> that the new mark to be visible after the functions returns. (Mostly
> for curiosity, not an actual problem.)
> 
> I want something like this:
> 
> ;--
> #lang racket/base
> 
> (define (display-cm-x)
>  (displayln
>   (continuation-mark-set->list
>    (current-continuation-marks) 'x)))
> 
> (define (add-cm-x v)
>  '???)
> 
> (define-syntax-rule (with-cm-x v body ...)
>  (with-continuation-mark 'x v
>    body ...))
> 
> (let ()
>  (display-cm-x) ;==>()
>  (with-cm-x 7
>    (display-cm-x)) ;==>(7)
>  (display-cm-x) ;==>()
>  (add-cm-x 7)
>  (display-cm-x) ;actual==>(), expected==>(7)
>  )
> ;--
> 
> The last line prints (), but I wish it prints (7).

This is going to sound flip, but … it sounds like you don’t want continuation marks. The whole point of continuation marks is that they’re associated with continuations, and will disappear when those continuations are gone.

The example you give isn’t quite enough to figure out exactly what you want; it sounds like some combination of fluid-let and … something else.

Maybe you can describe why it is that you want this behavior?

John



Posted on the users mailing list.