Thanks, your explanation is very clear. But now I realize that I was confused about what ocaml-multicont implements: I thought it involved using
clone_continuation in the usual (fragile) way, but from your explanation I see that it is substantially better. In fact it would suffice to have as an unsafe interface
external share : ('a, 'b) continuation -> ('a, 'b) resumption
external copy : ('a, 'b) resumption -> ('a, 'b) continuation
share turns a linear continuation into a shareable resumption (A -o !A… assuming the continuation only captures resumptions, not continuations, so promotion is sound), and
copy provides a linear copy of the shareable resumption (!A -o A).
(I think this is how existing “continuations” implementations, the
call/cc one for bytecode and now
delim/cc work, except they don’t expose the linear continuations as a first-class concept, they are just stack fragments that must be continued right after their recreation by a copy.)
I think that the current implementation itself confuses the matter (for me) by presenting resumptions exactly as continuations, programmed using a fairly different interface.