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

Any way to "join" a currently-active Continuation in Kotlin Coroutines?

I feel like I'm close here. Let's say I have a method with a suspendCancellableCoroutine: (Sorry for any syntactical/etc. errors, just trying to get an idea down) suspend fun foo(): String { suspendCancellableCoroutine { val listener =…
Codepunk
  • 188
  • 1
  • 12
0
votes
0 answers

The request is canceled in Swift

Good afternoon! I ran into the following problem: there is an execute function. @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) @discardableResult open func execute() async throws -> Response { try await…
0
votes
0 answers

Atlassian 1time TOTP - Java Implementation

I was attempting to implement this TOTP verification library created by Atlassian using java 1.8: Atlassian 1time totp library If I create a DefaultTOTPService, when I try to call any of its methods they are asking for a Continuation parameter. I…
Kachopsticks
  • 125
  • 1
  • 13
0
votes
0 answers

Scala 3. Recursive definition similar to Haskell recursive definition

exploring article on Continuation Monad while learning Scala 3. I understood the whole article and basically rewrote code into Scala 3 - except this single tricky goto function: {-# LANGUAGE ScopedTypeVariables #-} import qualified…
Max
  • 1,741
  • 3
  • 23
  • 40
0
votes
1 answer

Scala 3. Adapting Continuation monad example from Haskell to Scala

Learning Scala 3 with monadic topics. came across understandable breakdown of Continuation monad at https://jsdw.me/posts/haskell-cont-monad/ When I try to adopt simple code into Scala twoC = \out -> out 2 helloC = \out -> out "hello" ret val = \out…
Max
  • 1,741
  • 3
  • 23
  • 40
0
votes
1 answer

How to call kotlin suspend function from Java project

`I’m integrating one Sdk in my android Java project. In that Sdk they are having kotlin with suspend function. That I can’t call from my Java class as it forcing me to add continuation as param. I have searched many things but I couldn’t get clear…
Coder
  • 1
0
votes
1 answer

How to make async function using withCheckedContinuation either reentrant or prevent overwriting the continuation?

I have the following code: class Locator : NSObject, ObservableObject { private let locationManager: CLLocationManager private var authorizationContinuation: CheckedContinuation? @Published var…
meaning-matters
  • 21,929
  • 10
  • 82
  • 142
0
votes
0 answers

hex to utf-8 continuation byte pandas encoding latin-1

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 0: invalid continuation byte I have a pandas dataframe, which I import as latin-1, I get a specific column, which contains a url, use re.findall to get a hex code from the url. I…
0
votes
1 answer

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 is handled. What I mean is if the resume()…
Niko P
  • 41
  • 1
  • 3
0
votes
1 answer

How `set!` works in Racket when working with continuations?

I have this code working code based on an example from wikipedia (define (foo5) (define (control-state return) (define-syntax-rule (yield x) (set! return (call/cc (lambda (resume-here) …
geckos
  • 5,687
  • 1
  • 41
  • 53
0
votes
2 answers

How to return continuations in Racket?

I'm trying to build a good intuition behind continuations in Racket, I want to write a function that suspend it's execution and returns a continuation that when called continue the work from where it was suspended. I kind of achieved this with this…
geckos
  • 5,687
  • 1
  • 41
  • 53
0
votes
2 answers

F# CPS evaluation order

I'm trying to understand the order of evaluation when using Continuation-passing style in F#. Take this function for example. let rec CPSfunc n k c = if k = 0 then c 1 else if k > 0 then CPSfunc n (k-1) (fun res -> c(2*res+k)) When running…
Bassusour
  • 175
  • 6
  • 14
0
votes
0 answers

Autocompletion with Lucene

Is it possible to obtain continuations of a text depending on the content of the Lucene index? Does Lucene provide the API for this? For example, to query with a simple text consisting of a few words and to obtain possible continuations (a few…
0
votes
0 answers

Why continuation executes asynchronously?

The code sample below public static void Test() { TaskCompletionSource inner = new TaskCompletionSource(); TaskCompletionSource outer = new TaskCompletionSource(); TaskScheduler ctScheduler = new…
0
votes
1 answer

How to await an Array of async Tasks without blowing the stack?

A large array of Tasks blows the stack if you want to await them all, even if the array fold is stack-safe, because it yields a large deferred function call tree: const record = (type, o) => (o[type.name || type] = type.name || type, o); const…