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
2 answers

How do I know whether an expression is a continuation?

(+ 2 (let/cc cont (begin (set! global-cont cont) 3))) 5 global-cont # (global-cont 5) ; global-cont: (+ 2 _) 7 I know the whole block (+ 2 ... 3))) is a continuation. But why global-cont is a continuation also? I tried…
user8314628
  • 1,952
  • 2
  • 22
  • 46
0
votes
1 answer

Unix command line continuation

I am running a command to create a new directory. I am putting the \ at the 80th column and continuing onto the next line. The \ is being treated as a space. I have confirmed that there is no space after the \. sh mkdir…
AMS_1989
  • 13
  • 2
0
votes
1 answer

Handling UnobservedTaskException

I've an application that is configured to catch any unobserved task exceptions having ThrowUnobservedTaskExceptions enabled="true" in app.config. I've a library class(Class1) that needs to start an async task in it's constructor, but in some…
Rajesh Nagpal
  • 1,088
  • 1
  • 9
  • 12
0
votes
0 answers

Tips to transform a simple program in continuation programming?

For example I would like to do some NLP text treatment : extract some keywords, and find correlation between them (with previous lemma-POS segmentation). The Pipeline would be : count all (lemmatised) words, make a stopwords list, …
0
votes
1 answer

Is there macros for rewrite CPS?

For example I have two async methods (get-a 10 (lambda (a) (get-b a (lambda (b) (display b))) but I want to write something similar to (define (a (get-a 10))) (define (b (get-b a))) (display b)
0
votes
1 answer

Threading continuations confusion?

I have a simple continuation type (similar to the Free monad): data C m a = C {runC :: (a -> m a) -> m a} toBeContinued :: Int -> C Maybe Int toBeContinued i = C $ \todo -> todo i continuing :: Int -> Maybe Int continuing i = Just 100 I'm then…
Babra Cunningham
  • 2,949
  • 1
  • 23
  • 50
0
votes
0 answers

Using Poor Mans Concurrency with continuations/free monads?

I'm wanting to create an interleaved thread with suspended functions, which I can pass a single function at the time of invocation. Basic continuation type: data ContT m a = ContT {runContT :: (a -> m a) -> m a} suspendedFunction :: Int -> ContT…
Babra Cunningham
  • 2,949
  • 1
  • 23
  • 50
0
votes
2 answers

Continuation function implementations based upon input type?

I have a very simple continuation function (avoided using Monads for simplicity sake): data C a = C {unwrap :: (a -> a) -> a} Essentially, I'm trying to perform different implementations based on input type, something similar to (sudo-code): data…
Babra Cunningham
  • 2,949
  • 1
  • 23
  • 50
0
votes
2 answers

TPL: Task.Factory.ContinueWhenAll with AttachedToParent

The description of AttachedToParent states AttachedToParent: Specifies that the continuation, if it is a child task, is attached to a parent in the task hierarchy. The continuation can be a child task only if its antecedent is also a child task.…
Rob
  • 4,327
  • 6
  • 29
  • 55
0
votes
1 answer

How do spray's directives correspond to continuations?

I fail to see how spray's directives correspond to continuation passing style (CPS). More specifically, a continuation is (a -> r) -> r (in Haskell), but I cannot find where is this type ((a -> r) -> r) when using spray directives (which have the…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
0
votes
1 answer

shared_ptr vs. new operator: which one to use

In the function below I have made use of http_client from cpprestsdk (https://github.com/Microsoft/cpprestsdk) to make http requests to a network camera. The function below is probably a callback called by the lcm library…
0
votes
1 answer

How to get the user-slection of a dialog from MahApps using task continuation

I am using MahApps and I am trying to implement an abort-dialog if a user cancels a print-process. Since I am still using .Net 4.0 I cannot use await, but need to use continuations as stated here: However for the life of me I cannot figure out how…
packoman
  • 1,230
  • 1
  • 16
  • 36
0
votes
1 answer

Cooperative Threading, No assignment

To preface I love rolling my own, this is an exercise for learning purposes, but I want to take the information from this exercise eventually and implement some macros encapsulating the behaviors here. Thats why im using alot of let because nothing…
Anandamide
  • 243
  • 1
  • 15
0
votes
0 answers

Using more than two coroutines

So I have the following "cor.scm" (define (range-gen str stp inc) (call/cc (lambda (yield) (yield (lambda () (let ([i str]) (cond ([< str stp] (set! str (+ i inc)) i) …
Anandamide
  • 243
  • 1
  • 15
0
votes
1 answer

Writing an interpreter for a language with breaks

I'm trying to write an interpreter for a simple programming language in Scheme. Right now, I'm writing a procedure to handle while-loops with break statements. To approach this problem, I'm using call/cc. When the language is parsed, it looks like…