9.5 Continuation Marks
See Continuation Frames and Marks and Prompts, Delimited Continuations, and Barriers for general information about continuation marks.
The list of continuation marks for a key k and a continuation C that extends C0 is defined as follows:
If C is an empty continuation, then the mark list is null.
If C’s first frame contains a mark m for k, then the mark list for C is (cons m lst), where lst is the mark list for k in C0.
If C’s first frame does not contain a mark keyed by k, then the mark list for C is the mark list for C0.
The with-continuation-mark form installs a mark on the first frame of the current continuation (see Continuation Marks: with-continuation-mark). Procedures such as current-continuation-marks allow inspection of marks.
Whenever Racket creates an exception record for a primitive exception, it fills the continuation-marks field with the value of (current-continuation-marks), thus providing a snapshot of the continuation marks at the time of the exception.
When a continuation procedure returned by call-with-current-continuation or call-with-composable-continuation is invoked, it restores the captured continuation, and also restores the marks in the continuation’s frames to the marks that were present when call-with-current-continuation or call-with-composable-continuation was invoked.
procedure
(continuation-marks cont [prompt-tag]) → continuation-mark-set?
cont : (or/c continuation? thread? #f)
prompt-tag : continuation-prompt-tag? = (default-continuation-prompt-tag)
procedure
(current-continuation-marks [prompt-tag])
→ continuation-mark-set?
prompt-tag : continuation-prompt-tag? = (default-continuation-prompt-tag)
(call-with-current-continuation (lambda (k) (continuation-marks k prompt-tag)) prompt-tag)
procedure
(continuation-mark-set->list mark-set key-v [ prompt-tag]) → list? mark-set : continuation-mark-set? key-v : any/c
prompt-tag : continuation-prompt-tag? = (default-continuation-prompt-tag)
procedure
(make-continuation-mark-key sym) → continuation-mark-key? sym : symbol?
The optional sym argument, if provided, is used when printing the continuation mark.
procedure
(continuation-mark-set->list* mark-set key-list [ none-v prompt-tag]) → (listof vector?) mark-set : continuation-mark-set? key-list : (listof any/c) none-v : any/c = #f
prompt-tag : continuation-prompt-tag? = (default-continuation-prompt-tag)
procedure
(continuation-mark-set-first mark-set key-v [ none-v prompt-tag]) → any mark-set : (or/c continuation-mark-set? #f) key-v : any/c none-v : any/c = #f
prompt-tag : continuation-prompt-tag? = (default-continuation-prompt-tag)
procedure
(call-with-immediate-continuation-mark key-v proc [ default-v]) → any key-v : any/c proc : (any/c . -> . any) default-v : any/c = #f
This function could be implemented with a combination of with-continuation-mark, current-continuation-marks, and continuation-mark-set->list, but call-with-immediate-continuation-mark is implemented more efficiently; it inspects only the first frame of the current continuation.
procedure
v : any/c
procedure
v : any/c
procedure
(continuation-mark-set->context mark-set) → list?
mark-set : continuation-mark-set?
Conceptually, the stack-trace list is the result of continuation-mark-set->list with mark-set and Racket’s private key for procedure-call marks. The implementation may be different, however, and the results may merely approximate the correct answer. Thus, while the result may contain useful hints to humans about the context of an expression, it is not reliable enough for programmatic use.
A stack trace is extracted from an exception and displayed by the default error display handler (see error-display-handler) for exceptions other than exn:fail:user (see raise-user-error in Raising Exceptions).
Examples: | ||||||||||||||||||||||||||||||||||||
|