[racket] Confusing behavior with continuation-marks

From: Casey Klein (clklein at eecs.northwestern.edu)
Date: Sat Jan 15 08:00:11 EST 2011

On Sat, Jan 15, 2011 at 12:49 AM, Eric Dobson <endobson at cs.brown.edu> wrote:
> I was looking at the documentation on how continuation-marks work, and
> the documented behavior is different than what I observed.
>
> The following programs add a continuation mark, then a prompt, then
> try to look at the current continuation marks. According to the
> documentation I would expect the programs not to find a continuation
> mark, but in some cases it does. Here are the 6 variations and their
> returned values.
>
>
> #lang racket
> (define key 'key)
> (define value 'value)
> (with-continuation-mark key value
>  (call-with-continuation-prompt
>   (lambda ()
>     (continuation-mark-set-first
>      #f
>      key))))
>
> (with-continuation-mark key value
>  (call-with-continuation-prompt
>   (lambda ()
>     (continuation-mark-set-first
>      (current-continuation-marks)
>      key))))
>
> (with-continuation-mark key value
>  (call-with-continuation-prompt
>   (lambda ()
>     (continuation-mark-set-first
>      (current-continuation-marks (default-continuation-prompt-tag))
>      key))))
>
> (with-continuation-mark key value
>  (call-with-continuation-prompt
>   (lambda ()
>     (continuation-mark-set-first
>      #f
>      key
>      (default-continuation-prompt-tag)))))
>
> (with-continuation-mark key value
>  (call-with-continuation-prompt
>   (lambda ()
>     (continuation-mark-set-first
>      (current-continuation-marks)
>      key
>      (default-continuation-prompt-tag)))))
>
> (with-continuation-mark key value
>  (call-with-continuation-prompt
>   (lambda ()
>     (continuation-mark-set-first
>      (current-continuation-marks (default-continuation-prompt-tag))
>      key
>      (default-continuation-prompt-tag)))))
>
> =>
> 'value
> #f
> #f
> 'value
> #<continuation-prompt-tag:default>
> #<continuation-prompt-tag:default>
>

FWIW, the non-false results seem wrong to me too.


Posted on the users mailing list.