I'm studying Oleg's and Asai's delimited continuations "for dummies" paper(http://pllab.is.ocha.ac.jp/~asai/cw2011tutorial/main-e.pdf) but this paper uses the shift/reset formalism instead of the prompt stuff available in Oleg's delimcc. So I have a few questions:
First of all, what is a prompt? And why is passed down in shift and other functions?. Knowing what is subcont would be nice as well but I'm willing to skip that since I Just want to get through the paper. Also, what is the difference between shift and shift0 and how do they correspond to shift in the paper.
Also, what is reset in delimcc? My gut feeling is telling me that new_prompt and push_prompt somehow correspond to reset. But I need some clarification here as well.
EDIT: I was able to translate a simple example from the paper and my intuition turned out right. However I'd like a real explanation of the differences and why is delimcc is they way it is. Here's both versions in case anyone is interested
Paper:
reset (fun () -> 3 + shift (fun _ -> 5 * 2) - 1)
Delimcc:
let _ = let open Delimcc in
let np = new_prompt () in
push_prompt np (fun () -> 3 + (shift np (fun _ -> 5 * 2)) - 1)
I would recommend that you read the beginning of this paper, which is the journal version of Oleg's presentation of
delimcc. This would get you a reasonable understanding ofdelimccthat would let you port the shift/reset example of your article todelimcc's multi-prompt setting.Two quotes that may interest you. The first is from the journal version I pointed above:
The second is from GNU Guile's documentation
To conclude: you're right that calling
new_promptto get a prompt and thenpush_promptto install it is the way to getreset. In fact, you only need to callnew_promptonce, and can push always to this same global prompt, and get the usualshift/resetbehavior (declaring different prompts only give you some more freedom).Finally,
shiftis definable with the primitives ofdelimcc, and this is what is done in the library.shiftcallstake_subcont, immediately reinstalls the (same) prompt, and provides to the user a function that would restart the aborted computation.shift0does the same thing, except it does not reinstall the prompt. In thedelimcccode: