[racket] Confusing behavior with continuation-marks
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>
-Eric