Questions tagged [continuations]

21 questions
24
votes
2 answers

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 using continuation-passing style (CPS) is a bit…
CinchBlue
  • 614
  • 4
  • 16
12
votes
1 answer

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 performance in SML/NJ. Its physical evaluation…
11
votes
1 answer

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 in e.g. Scheme and SML/NJ). For sake of…
user21412
6
votes
2 answers

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 topics, but I'm looking for a reference which also…
6
votes
0 answers

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 and intuitionistic logic) I searched the internet,…
chansey
  • 295
  • 1
  • 8
5
votes
1 answer

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 \kappa x} \\ {[[\lambda x \cdot M]]=\lambda \kappa…
Shuumatsu
  • 151
  • 3
4
votes
1 answer

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 continuation-passing style (i.e., I've read through most of the…
4
votes
3 answers

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 of text in question follows: As Flanagan et al.…
4
votes
1 answer

Tail call optimization via translating to CPS

I am struggling to wrap my head around this compiler technique, so let's say here's my factorial function def factorial(value: int) -> int: if value == 0: return 1 else: return factorial(value-1) * value It is recursive, but…
4
votes
1 answer

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$-calculus have the power to model call/cc, is it…
Earth Engine
  • 375
  • 1
  • 8
4
votes
1 answer

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 continuations in terms of single-prompt delimited…
river
  • 163
  • 6
3
votes
0 answers

Examples of continuations in pure mathematics

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 structures of some kind, and quite apart from…
3
votes
2 answers

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 returns. I have found numerous examples of other…
00prometheus
  • 171
  • 7
2
votes
0 answers

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$ and $y$ in the domain. It should be continued to…
Igor
  • 21
  • 1
2
votes
0 answers

Is there a proof of correctness for CPS translations into Appel's IR?

The IR given in Appel's book (Compiling with Continuations) is certainly well explored and battle-tested in production compilers. I have been able to find several works based on or inspired by it (either by Appel himself, such as Shrinking Lambda…
paulotorrens
  • 731
  • 3
  • 11
1
2