[racket] Behavior of continuation-mark-set->list and continuation-mark-set-first with respect to key values

From: Galler (lzgaller at optonline.net)
Date: Sun May 6 00:02:13 EDT 2012

BACKGROUND:

Per the documentation:

with-continuation-mark  causes a key to be associated with a binding 
within a continuation frame

continuation-mark-set->list returns the binding(s) associated with that 
particular key, for any given continuation-mark-set

while

continuation-mark-set-first returns the first (innermost) binding 
associated with a particular key

QUESTIONABLE  BEHAVIOR

The issue is:

if a key is reused, the only binding continuation-mark-set->list returns 
is the innermost binding.

So continuation-mark-set->list could only possibly return **one** value

and

continuation-mark-set-first  appears redundant

Is that the desired behavior? I would have expected 
continuation-mark-set->list to return all the bindings for a particular 
key.

Additionally, I suspect continuation-mark-set->context has to be 
implemented using the 'return a list of all bindings for a single key' 
behavior, since the documentation indicates it uses a single private 
key.


EXAMPLE

#lang racket
(with-continuation-mark 'global  'outermost-value
   (let/cc k-outer
     (with-continuation-mark 'global 'middle-value
       (let/cc k-inner
         (with-continuation-mark 'global 'inner-value (begin
                                                        (display 
(continuation-mark-set->list (current-continuation-marks) 'global))
                                                        (newline)
                                                        (display 
(continuation-mark-set->list (continuation-marks k-inner) 'global))
                                                        (newline)
                                                        (display 
(continuation-mark-set->list (continuation-marks k-outer) 'global))
          ))))))

;Returns

;(inner-value)

;(middle-value)

;(outermost-value)

but I would have expected:

;Returns

;(inner-value) (middle-value) (outermost-value)

;(middle-value) (outermost-value)

;(outermost-value)


Thanks very much for looking at this.

R/

Zack

Posted on the users mailing list.