Skip to content

Questions

rain1 edited this page May 27, 2019 · 13 revisions

What is the relationship between CPS-hierarchy integer indexed continuations and the abstract multi-prompt continuations?

CPS-hierarchy integer indexed continuations show up in: [Control Delimiters and their heirarchies], [(1994) Subcontinuations], [operational foundation for delimited continuations in the CPS heirarchy]

abstract multiple prompt ones show up in: [(1995) A generalization of exceptions and control in ML-like languages], [(2005) A Monadic Framework for Delimited Continuations], [(2006) Delimited Dynamic Binding]

Are continuations related in some way to the derivative of defunctionalized code?

Arose from the fact you can do zippers in two ways: derivatives of yielding control. Zipper: a derivative of a data structure or of its mapping

Should prompts be lexically scoped or dynamically scoped?*

There is a tight connection between dynamic scope and multiprompt continuations [Delimited Dynamic Binding] [A Systematic Approach to Delimited Control with Multiple Prompt]. Perhaps lexically scoping the prompts is unnatural?

How do we related multi-prompt delimited continuations to algebraic effect handlers

We know the link between monads and delimited continuations. And we have seen that effects are more general than monad transformers. What would the exact link between the two be?

Motivation for multiple prompts: Why do we need multiple prompts?

  • Supporting correct interaction between dynamically bound variables and control operators.
  • Correct interaction between any two language features implemented using control operators(?)

The work on exceptions is pretty good motivation. All the methods without multiple prompts are awkward.

How would multiprompt approach of implementing exceptions relate to the multiprompt approach of implementing generators

We presume that all multiprompt definitions will interact "correctly". Test this out and see what happens in practice. Using e.g. [2012-systematic-approach-multi-prompts-exceptions.rkt]

Which was the paper that uses twice CPS to give semantics to shift/reset?

Abstracting Control - Olivier Danvyy, Andrzej Filinsk (1990)

How do I implement delimited continuations?

My answer from reddit, not a perfect answer but provides some starting points:

Delimited continuations have been described by performing CPS transformation twice in (1990) Abstracting Control - Olivier Danvy, Andrzej Filinski, but this wouldn't be a good or efficient way to actually implement them.

The delimited continuation operators can be implemented using the call/cc primitive. For example http://okmij.org/ftp/Scheme/delim-control-n.scm http://okmij.org/ftp/Scheme/delimcc.scm

you can also implement them directly by coping segments of the control stack: (1990) Representing Control in the Presence of First-Class Continuations - Robert Hieb, R Kent Dybvig, Carl Bruggeman and the Scheme48 paper (2002) Final Shift for CallCC Direct Implementation of Shift and Reset - Martin Gasbichler, Michael Sperber

Or you can implement them with a virtual machine following (2010) Functional derivation of a virtual machine for delimited continuations - Kenichi Asai, Arisa Kitani

Alternatively it is possible to build an interpreter with (multi-prompt) delimited continuations by using the monad from the paper (2005) A Monadic Framework for Delimited Continuations - Kent Dybvig, Simon Peyton Jones, Amr Sabry.

Can you implement multi-prompt delimited continuations using single-prompt delimited continuations?

I'm not sure. I think it may be possible with dynamic binding, and you can implement that with delimited continuations right?

Are delimited continuations and call/cc equivalent or is one more expressive than the other?

Delimited continuations are more expressive.

The Filinski paper (Representing Monads) shows that you need a mutable cell to implement delimited continuations using call/cc. This was summarized in Compositional Semantics for Composable Continuations - From Abortive to Delimited Control:

In his seminal work, Filinski [15] showed a different notion of completeness for delimited control in call-by-value functional languages: every computational effect that can be encoded as a monad can be directly expressed by delimited control operators. This property does not hold for classical control — for example, neither callcc nor C are able to express mutable references.

Clone this wiki locally