[racket] Continuation marks

From: Gustavo Massaccesi (gustavo at oma.org.ar)
Date: Fri Sep 5 17:24:59 EDT 2014

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).

Gustavo

Posted on the users mailing list.