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.

continuations
Filter by
Sorted by
Tagged with
4 votes
3 answers
3k views

Static variables in Scheme/Racket?

In C, you can have a static variable within a method, which can remember values to which it was set by previous calls of the method. I heard that the same effect can be found by using continuations ...
djhaskin987's user avatar
  • 9,932
3 votes
3 answers
387 views

scheme continuations -need explanation

The following example involves jumping into continuation and exiting out. Can somebody explain the flow of the function. I am moving in a circle around continuation, and do not know the entry and exit ...
hrishikeshp19's user avatar
4 votes
4 answers
959 views

Emulate/use Continuations in JavaScript?

I have a function that computes product of numbers in an array. The function should work like this function prod (array){ //compute and return product } var arr = [1,2,3,0,4,5,0,6,7,8,0,9]; the ...
hrishikeshp19's user avatar
0 votes
2 answers
285 views

Simple Async operation with Continuation scenario doesn't work on a WPF app

I have a really simple operation on a WPF app in order to try out async operations. Here is my complete code: static int GetPrimes() { var query = from n in Enumerable.Range(3, 5000000)....
tugberk's user avatar
  • 58.1k
10 votes
3 answers
430 views

how can I implement this monad transformer with a continuation?

motivation. I'm trying to create a monad transformer, with a special instruction f <||> g that means "repeat this entire block containing f <||> g, once with f, the next time with g". This ...
gatoatigrado's user avatar
  • 16.7k
10 votes
2 answers
859 views

Are continuations a key feature in Seaside?

I'm trying to get up to speed on Smalltalk / Seaside. According to Wikipedia, "Seaside is a continuation-based web application framework". Coming from a Java background I'm not very familiar with ...
Justin's user avatar
  • 6,201
7 votes
1 answer
1k views

Play's continuations holding http threads

We have implemented a feature in our web app that updates the GUI in response to new events in the server by using Play's continuations, just like a chat app. After running it for some time in ...
Célio's user avatar
  • 573
10 votes
2 answers
902 views

Haskell implemented without a stack?

from How does a stackless language work? Haskell (as commonly implemented) does not have a call stack; evaluation is based on graph reduction. Really? That's interesting, because while I've never ...
TheIronKnuckle's user avatar
5 votes
2 answers
616 views

Continuation, callcc method is not defined

I wanted to learn something about Continuation, type several examples from some articles with callcc method and I've got the error: NoMethodError: undefined method `callcc' for main:Object from (pry):...
megas's user avatar
  • 21.7k
3 votes
3 answers
1k views

Scheme - converting to continuation-passing style

I kinda understand how to convert elementary functions such as arithmetics to continuation-passing style in Scheme. But what if the function involves recursion? For example, (define funname (...
CosmicRabbitMediaInc's user avatar
9 votes
1 answer
5k views

How can C++ use continuation-passing style?

Suppose in C++ you're doing too many recursive calls on a recursive function and getting a stack overflow error. How would you rewrite this in a continuation-passing style to avoid the stack overflow?...
achow's user avatar
  • 1,005
13 votes
2 answers
5k views

How do I schedule a conditional ContinueWith

I have some GUI on a bunch of LINQ queries. The queries take some time to execute, so I would like for the GUI to be responsive and show busyindicators and progress bars. Many of the queries are to ...
Tormod's user avatar
  • 4,551
6 votes
4 answers
1k views

How can I avoid using the stack with continuation-passing style?

For my diploma thesis I chose to implement the task of the ICFP 2004 contest. The task--as I translated it to myself--is to write a compiler which translates a high-level ant-language into a low-...
Bela's user avatar
  • 113
20 votes
7 answers
251k views

syntaxerror: "unexpected character after line continuation character in python" math

I am having problems with this Python program I am creating to do maths, working out and so solutions but I'm getting the syntaxerror: "unexpected character after line continuation character in python"...
Arcticfoxx's user avatar
4 votes
1 answer
241 views

variadic bind in Haskell

The following code is an attempt to write a variadic function that acts like this: bind_variadic mx f = mx >>= f bind_variadic mx my f = do { x <- mx; y <- my; f x y } I can write it if ...
gatoatigrado's user avatar
  • 16.7k
61 votes
5 answers
14k views

Async/Await - is it *concurrent*?

I've been considering the new async stuff in C# 5, and one particular question came up. I understand that the await keyword is a neat compiler trick/syntactic sugar to implement continuation passing, ...
Neil Barnwell's user avatar
2 votes
1 answer
2k views

Continuations usage in play framework example needed

Can you give me some links with good examples how to use continuations in play framework?(beside source of play framework, their 'samples-and-tests' and on-site doc, already were there) Any ...
Mike Stetsyshyn's user avatar
10 votes
3 answers
3k views

Continuations in Java [closed]

I am looking for recent work presenting continuations in Java. I have come across the same question here but it dates back for a year or two. There is some work such as JavaFlow by Apache, RIFE ...
nobeh's user avatar
  • 9,909
4 votes
3 answers
907 views

Continuation Passing Style (CPS) during graph construction

I am working on a library for subdivision surfaces. In order to represent the mesh topology I'm using a kind of split-vertex lath data structure (see the diagram on the left side). During the ...
LambdaStaal's user avatar
4 votes
1 answer
466 views

Nemerle actors/coroutines & Mono Continuations

I found this article: http://www.mono-project.com/Continuations So I have a few questions about it. Are there any implementations of erlang-style or (at least) scala-style actors for Nemerle based on ...
gordon-quad's user avatar
0 votes
1 answer
442 views

Re-execute TRY block after the exception is handled

Starting from this answer: Scala continuation and exception handling I would like to know if there is a way to re-execute the ENTIRE try block (or ctry block in the example code) after the exception ...
Niko P's user avatar
  • 41
0 votes
1 answer
463 views

Action Chaining Not Redirecting After Controller.await(int millis)

I'm not sure if this isn't working as intended of it it's just me getting confused. What I would like to do is to asynchronously delay an action, and await(int millis) and I seem to be able to become ...
Tobias's user avatar
  • 1
12 votes
2 answers
948 views

Converting Scala @suspendable Method into a Future

suppose I have a sleep function: def sleep(delay:Int) : Unit @suspendable = { .... } is it possible to have a function future that creates an async version of the sleep function that can be ...
benmmurphy's user avatar
  • 2,503
22 votes
2 answers
976 views

How to make callCC more dynamic?

I thought the right type for ContT should be newtype ContT m a = ContT {runContT :: forall r. (a -> m r) -> m r} and other control operators shift :: Monad m => (forall r. (a -> ContT m ...
bobzhang's user avatar
  • 1,781
5 votes
0 answers
412 views

Why in Ruby 1.9 Continuations are evil? [closed]

I am relative new in Ruby world. And I don't know, what to think. In 'The Ruby Programming Language' I read I shouldn't use Continuations in new code and use Fibers instead. I found this presentation (...
guest's user avatar
  • 1,695
1 vote
3 answers
299 views

F# continuations goes on StackOverflowException

Hi guys I'm implementing an F# function that takes two lists of type : (int*float) list. These two lists have different lentgths. The int element of the couple is an increasing code. What I wanted to ...
Fr.Usai's user avatar
  • 384
7 votes
3 answers
587 views

Understanding continuations in JavaScript

I'm trying to solve the last exercise of this JavaScript Closure Tutorial which takes about Continuation Passing. This is the exercise: Define a function named bothC similar to seqC that takes ...
helpermethod's user avatar
  • 60.7k
11 votes
1 answer
576 views

Using Scala continuations for non-blocking APIs

I'm trying to use Scala (2.9.0) continuations to build a seemingly blocking API, but that actually is asynchronous. Suppose that you would like to write something like: if(ask("Continue?")) //Prompts ...
juancn's user avatar
  • 2,533
2 votes
2 answers
826 views

Continuations: can I serialize the continuation in an F# async workflow or C# async function?

I want a serializable continuation so I can pickle async workflows to disk while waiting for new events. When the async workflow is waiting on a let!, it would be saved away along with a record of ...
Sebastian Good's user avatar
9 votes
3 answers
1k views

Escaping from the IO monad inside the Continuation monad

A confusing title for a confusing question! I understand a) monads, b) the IO monad, c) the Cont monad (Control.Monad.Cont), and d) the ContT continuation transformer monad. (And I vaguely understand ...
mgiuca's user avatar
  • 21.1k
5 votes
2 answers
679 views

CPS compiler for coroutine implementation

I used to work on IronLua in my spare time. Lexing and parsing is currently done. I kind of stopped working on it out of frustration since implementing Lua coroutines in .NET without resorting to ...
raine's user avatar
  • 827
5 votes
3 answers
1k views

How does Smalltalk manipulate call stack frames (thisContext)?

The Smalltalk object thisContext look strange and marvelous. I can't understand what it is and how it works. And even how it enables continuations. For C's call-stack, I can easily imagine how is it ...
eonil's user avatar
  • 84.8k
7 votes
2 answers
237 views

How could I implement an early return from outside the body of a method in Scala?

Disclaimer: Before someone says it: yes, I know it's bad style and not encouraged. I'm just doing this to play with Scala and try to learn more about how the type inference system works and how to ...
Jean-Philippe Pellet's user avatar
9 votes
2 answers
297 views

Example of nested resets in Scala

This is a question about Scala continuations. Can resets be nested? If they can: what are nested resets useful for ? Is there any example of nested resets?
Michael's user avatar
  • 10.2k
4 votes
2 answers
181 views

Does it matter where a shift stands in a reset block?

Suppose, there is a reset block with a single shift: val r = reset { // do smth. 1 shift {...} // do smth. 2 // do smth. 3 } Is it correct that I place the shift after "do smth. 2" or "...
Michael's user avatar
  • 10.2k
5 votes
1 answer
173 views

How is a reset with two shifts reified in Scala?

I understand from this blog post how a single shift within a reset is reified. reset { 1 + shift {k:Int => Int => k(5)} + 1} is reified to val reified = {shiftValue:Int => 1 + shiftValue + 1}; ...
Michael's user avatar
  • 10.2k
10 votes
3 answers
2k views

Scala continuation and exception handling

Suppose, I would like to catch an exception, fix the problem caused the exception and return to the same execution point where the exception occurred to continue. How can I implement it with ...
Michael's user avatar
  • 10.2k
2 votes
2 answers
3k views

jetty 7 continuations

i'm using jetty-7.4.1.v20110513 and servlet-api-2.5 i tried to use continations in the following servlet. import java.io.*; import java.util.*; import javax.servlet.ServletException; import ...
ravi's user avatar
  • 838
3 votes
1 answer
265 views

Understanding undelimited continuations

Suppose, I have the following code (in C-like syntax): void foo(int arg) { ... } int bar() { ... // call with continuation ... } foo ( bar() ) // after foo invocation 1) Function foo invokes ...
Michael's user avatar
  • 10.2k
6 votes
2 answers
2k views

Scala delimited continuations error at runtime

Scala newbie here, I just downloaded Eclipse 3.6.2 and Scala IDE 2.0.0-beta4 (with Scala 2.9.0.final). I create a new Scala project to try delimited continuations: package delimCCTests import scala....
Mauricio Scheffer's user avatar
5 votes
3 answers
1k views

Event listeners with Scala continuations

Suppose I have to write some GUI code as follows: widget1.addListener(event1 => handle1(event1) widget2.addListener(event2 => handle2(event2) widget3.addListener(event3 => handle3(...
Michael's user avatar
  • 10.2k
12 votes
2 answers
2k views

Difference between delimited and undelimited continuations

I guess the difference between delimited and undelimited continuations is like the difference between call and jump. If we invoke delimited continuation it will return to the caller once it finishes. ...
Michael's user avatar
  • 10.2k
4 votes
1 answer
489 views

Question about Scala continuation

As I understand shift and reset are just library functions. Is it correct that all continuation stuff is implemented as a library and Scala compiler does not do any special work to transform the code ...
Michael's user avatar
  • 10.2k
4 votes
1 answer
323 views

Question about reification

I am reading a blog post about continuations, which describes how the reset block is reified. Can anybody formulate the exact rule of that reification?
Michael's user avatar
  • 10.2k
12 votes
1 answer
457 views

Does "reset" require "shift" inside the block?

Is it correct that reset requires shift inside the block? I tried it and got the following: scala> reset {} error: cannot cps-transform expression (): type arguments [Unit,Unit,Nothing] do not ...
Michael's user avatar
  • 10.2k
14 votes
2 answers
1k views

"call-cc" patterns in Scala?

I found a good article, about call with current continuation patterns. As I understand, they use Scheme and undelimited continuations. Can the patterns from the article be implemented in Scala? Is ...
Michael's user avatar
  • 10.2k
2 votes
2 answers
226 views

Environment not part of a continuation?

Is the environment not part of a continuation in scheme? I have tested this with Chicken, Gauche, Racket and Gambit, and they all behave similarly: (define kont #f) (let ((a 1) (b 2)) (call-...
josh's user avatar
  • 997
2 votes
2 answers
430 views

Example of using Scala delimited continuations for GUI programming

I guess Scala delimited continuations can be successfully used to implement GUI event listeners with any Java GUI framework (e.g. Swing). Is there any simple but non-trivial example of using the ...
Michael's user avatar
  • 10.2k
34 votes
2 answers
2k views

Why are delimited continuation primitives named "shift" and "reset"?

I think I understand (in general) what shift and reset mean. However I do not understand why they are named so ? What do shift and reset as Delimited Continuation primitives have to do with "shift" ...
Michael's user avatar
  • 10.2k

1
8 9
10
11 12