Questions tagged [continuations]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
39 views

Continuation passing transform

I'm stuck on something in in Shan's article Shift to Control, about CPS. On page three he writes the CPS transform ...
user avatar
  • 115
0 votes
0 answers
25 views

Two CPS translations for CBV lambda calculus

I am looking for the CPS translation for CBV evaluation order in lambda calculus, and I have found the two following versions of the translation. The first is given there: https://www.cs.cornell.edu/...
user avatar
  • 565
-1 votes
1 answer
117 views

Pattern finding in an array of numbers

I have an array of numbers, and I need to check if there is a repeating pattern in the array. Like, for example, if I have an array A=[1,1,6,1,1,6,1,1,6,1,1,6...] this should return "Yes" (...
user avatar
1 vote
0 answers
11 views

Is it possible to implement a defer statement with delimited continuations?

A defer statement takes another statement and evaluates the given statement at the end of the current function call. See how Go does it. Delimited continuations can be abused to provide throw/catch ...
user avatar
  • 13
1 vote
0 answers
25 views

Analogue of disjunction and existence properties for a Turing-complete programming language?

Quoting from Wikipedia: In mathematical logic, the disjunction and existence properties are the "hallmarks" of constructive theories such as Heyting arithmetic and constructive set theories ...
user avatar
1 vote
0 answers
80 views

Help me to make sure, that I got defunctionalized continuations right

I am reading this Defunctionalization at work paper. So, in order to ascertain that I got it right, I request a little code review. I'll start with a recursive definition of a factorial function and ...
user avatar
3 votes
0 answers
119 views

Understanding $\lambda \mu$-calculus in more programming way

I am learning $\lambda \mu$-calculus (self-study). I learned it because it seems very useful for understanding Curry-Howard correspondence (e.g understanding the connection between classical logic ...
user avatar
  • 247
2 votes
0 answers
32 views

How can we convert between a program using `call/cc` and a program using functions written in CPS?

The Scheme Programming Language says It turns out that any program that uses call/cc can be rewritten in CPS without call/cc, but a total rewrite of the program (sometimes including even system-...
user avatar
  • 1
5 votes
1 answer
57 views

Explain auto continue passing style transformations

Recently I saw 3 cps transformation rules, but no explanations were given. expressions: $e :=x\left|e e^{\prime}\right| \lambda x \cdot e$ rules: $$ \begin{array}{l}{[[x]]=\lambda \kappa \cdot \...
user avatar
  • 151
4 votes
1 answer
281 views

Multi-prompt delimited continuations in terms of single-prompt delimited continuations

Let's call the two languages in question (untyped lambda calculus with single or multiple prompt delimited continuations) L_delim and L_prompt. Is it possible to express multi-prompt delimited ...
user avatar
  • 163
1 vote
0 answers
48 views

Can you use CPS to simulate state in a stateless programming language?

In a language supporting CPS, but no built in global state, we can represent a state based computation using a function. We call this function a state function. Assume the function takes three ...
user avatar
  • 756
4 votes
1 answer
175 views

Continuation-passing style: what is meant by "CPS'ing"?

I'm reading Dijkstra Monads for Free for a presentation I'll be doing and it's pretty meaty. One of the things that I keep running into is the term "CPS'ing". I've read a little bit on ...
user avatar
3 votes
0 answers
87 views

Examples of continuations in pure mathematics [closed]

I am not a computer scientist and have no knowledge of programming. However, I wondered continuations occur as natural and interesting mathematical structures, perhaps as algebraic or type theoretic ...
user avatar
  • 194
19 votes
2 answers
4k views

Why is static-single assignment preferred over continuation passing style in many industry-used compilers?

According to the Wikipedia page on static-single assignment (SSA), SSA is used by large and well-known projects such as LLVM, GCC, MSVC, Mono, Dalvik, SpiderMonkey, and V8 while the page on projects ...
user avatar
  • 552
2 votes
0 answers
111 views

Continuation of strictly monotone function on a plane

I have a computational problem where I'm given the values of a function $f(x,y)$ sampled on 2D regular grid. The function is given in a compact domain of a grid and it is strictly monotone w.r.t. $x$ ...
user avatar
  • 21
11 votes
1 answer
552 views

When used as call stack, do garbage-free spaghetti stacks form a DAG?

I'm looking into implementation techniques for programming languages, and recently came across spaghetti stacks, which are supposedly a good fit for a continuation passing style model (given their use ...
user avatar
  • 212
3 votes
2 answers
969 views

How would I write an if-statement in continuation passing style without an if-statement?

Using continuation passing style, many common language constructs can be written in a simple language with recursion, including loops (using trampolining), exceptions, generators and even function ...
user avatar
4 votes
3 answers
168 views

What does it mean to be "closed" under beta reduction?

I am reading the paper Compiling with Continuations, Continued, and in section 2.4, Comparison with ANF, the author draws attention to the fact that ANF is not closed under beta reduction. The snippet ...
user avatar
6 votes
2 answers
241 views

Reference request: Monads, continuations, and other functional CS concepts

I've been using Clojure for about 18 months. Recently, I've come across terms such as Monads, Continuations, et al which I'd like to learn about. I could visit Wikipedia and read about these two ...
user avatar
4 votes
1 answer
869 views

Are there a lambda-mu expression equivalent to the yin yang puzzle?

The yin yang puzzle was written in Scheme. Since it uses call/cc, it is not possible to express it in a pure lambda expression, unless we do a CPS transform. However, given the fact that $\lambda \mu$...
user avatar
12 votes
1 answer
767 views

The "CPS" approach has done great harm to performance in SML/NJ; reasoning desired

In a comment to Learning F#: What books using other programming languages can be translated to F# to learn functional concepts? Makarius stated: Note that the "CPS" approach has done great harm to ...
user avatar
  • 5,032