Questions tagged [continuations]

In computer science and programming, a continuation is an abstract representation of the control state. A continuation reifies an instance of a computational process at a given point in the process's execution. It contains information such as the process's current stack (including all data whose lifetime is within the process e.g. "local variables"), as well the process's point in the computation.

Using continuation, when a function calls another function, that is the last thing it does. An extra argument is part of every function, which will be used to pass each function's continuation. Instead of waiting for the called function to return, it puts any work it wants to do afterwards into a continuation, which it passes to the function. Essentially, this involves breaking up the code into a collection of callback functions.

535 questions
0
votes
1 answer

Trampoline based linked list (lisp tree) to string with cycles

I have problem with my trampoline based function that stringify lisp list. Here is the code: function Pair(car, cdr) { this.car = car; this.cdr = cdr; } const nil = new function Nil() {}; //…
jcubic
  • 61,973
  • 54
  • 229
  • 402
0
votes
0 answers

Unable to define a Task using continueWith for a StreamDownloadTask

I'm trying to write a function in Kotlin that needs to return a Bitmap after getting a stream from a StorageReference object. Since I can't use a solution that implements listeners I have to define a Continuation and get the result when the…
Antonio Santoro
  • 827
  • 1
  • 11
  • 29
0
votes
2 answers

Is it possible to write continuations in C++?

I discovered about continuations while reading The Little Schemer by Friedman and Felleisen, and to practice a little with this concept I wrote a simple code that given a list of integers removes the evens and returns the sum of the odds. This is my…
J. D.
  • 279
  • 1
  • 9
0
votes
2 answers

Is CallCC an improved version of goto?

My background is Javascript, Python & a bit of Haskell. I am trying to understand callCC, there are many explanations but I can't find them trivial & I came across this https://www.cs.bham.ac.uk/~hxt/research/Logiccolumn8.pdf and I felt like I…
Pawan Kumar
  • 1,443
  • 2
  • 16
  • 30
0
votes
1 answer

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-defined primitives) might be necessary. What are…
user10082400
0
votes
0 answers

Do the continuation created by `call/cc` and the continuation used for making a call to a function in CPS both make jump?

When a continuation is called as a procedure, does some jump occur? For example, I have seen two use cases of continuation: Are the continuation created by call/cc and the continuation used for making a call to a function in CPS the same concept,…
user10082400
0
votes
1 answer

What determines the number and types of values a continuation can be applied to?

The Scheme Programming Language says Scheme allows the continuation of any expression to be captured with the procedure call/cc. call/cc must be passed a procedure p of one argument. call/cc constructs a concrete representation of the current…
user10082400
0
votes
2 answers

Issue with BAM Continuation for BizTalk

I have developed a BizTalk Application. It receives a xml file and, after applying the business logic, it sends the file to another location using FILE adapter. I need to track the start and end time for both Receive Port and Send Port. I have…
0
votes
1 answer

Is there something like stateful continuations or continuations with saved heap?

In functional programming, continuations are very useful because continuations store the program counter and stack; mutable heap is not necessary to save obviously. What about if you want to apply continuations in non-functional programming…
0
votes
1 answer

TaskContinuationOptions OnlyOnCancelled catches unhandled errors

I have following code to handle my TaskContinuations. I am bit confused because I have below OnlyOnFaulted block which I expect will be entered if the task throws an unhandled exception. However, unhandled exception, handled exception that is…
pixel
  • 9,653
  • 16
  • 82
  • 149
0
votes
1 answer

Do continuation record the PC and register states?

currently, when I am experimenting the continuation in functional languages, my understanding is that a continuation records the current program counter and register files, and when a continuation is returned, then the PC and the registered files…
user618815
0
votes
0 answers

What are the connection of continuation monads to Traversables/Observables/Futures in Scala?

The continuation monad, if written in Scala, is basically opaque type Cont[R, +A] = (A => R) => R This type signature, (A => R) => R, is suspiciously similar to foreach in Traversable/Future etc: def foreach[R](f: A => R) => Unit If written in a…
Tongfei Chen
  • 613
  • 4
  • 14
0
votes
2 answers

Understanding the continuation theorem in Scala

So, I was trying to learn about Continuation. I came across with the following saying (link): Say you're in the kitchen in front of the refrigerator, thinking about a sandwich. You take a continuation right there and stick it in your pocket. Then…
vesii
  • 2,760
  • 4
  • 25
  • 71
0
votes
0 answers

Continuation style call like .NET async-await in C++?

I'm working on a C++ project where I have to implement code some custom radio communication. This obviously cannot block the main thread at any point by waiting for a join(), a Future.get() etc. , but I'm really struggling to figure out how to do…
Bertramp
  • 376
  • 1
  • 15