continuations

Continuations in Java

假装没事ソ 提交于 2019-11-27 18:46:29
Is there a good implementation of continuations in Java? If so, what is the overhead like? The JVM wasn't designed with these sort of things in mind, right? So is this kind of going against the grain? See Apache Javaflow http://commons.apache.org/sandbox/javaflow/ It's the only continuation package for java that's actively under development. The other one, RIFE, I'm not sure which state it's in. Jerry Chan Javaflow http://commons.apache.org/sandbox/javaflow/ Play framework use Javaflow http://blog.heroku.com/archives/2011/8/29/play/ RIFE http://www.artima.com/lejava/articles/continuations.html

Continuations and for comprehensions — what's the incompatibility?

孤者浪人 提交于 2019-11-27 18:00:02
问题 I am new to Scala and trying to wrap my head around continuations I'm trying to reproduce the yield return C# statement. Following this post, I have written the following code : package com.company.scalatest import scala.util.continuations._; object GenTest { val gen = new Generator[Int] { def produce = { yieldValue(1) yieldValue(2) yieldValue(3) yieldValue(42) } } // Does not compile :( // val gen2 = new Generator[Int] { // def produce = { // var ints = List(1, 2, 3, 42); // // ints.foreach(

C# 5 Async/Await - is it *concurrent*?

戏子无情 提交于 2019-11-27 10:47:20
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 , where the remainder of the method is broken up into Task objects and queued-up to be run in order, but where control is returned to the calling method. My problem is that I've heard that currently this is all on a single thread. Does this mean that this async stuff is really just a way of turning continuation code into Task objects and then calling Application.DoEvents() after each task completes

scheme continuations for dummies

心已入冬 提交于 2019-11-27 10:31:57
问题 For the life of me, I can't understand continuations. I think the problem stems from the fact that I don't understand is what they are for . All the examples that I've found in books or online are very trivial. They make me wonder, why anyone would even want continuations? Here's a typical impractical example, from TSPL, which I believe is quite recognized book on the subject. In english, they describe the continuation as "what to do" with the result of a computation. OK, that's sort of

Coroutine vs Continuation vs Generator

跟風遠走 提交于 2019-11-27 09:57:04
What is the difference between a coroutine and a continuation and a generator ? Keith Gaughan I'll start with generators, seeing as they're the simplest case. As @zvolkov mentioned, they're functions/objects that can be repeatedly called without returning, but when called will return (yield) a value and then suspend their execution. When they're called again, they will start up from where they last suspended execution and do their thing again. A generator is essentially a cut down (asymmetric) coroutine. The difference between a coroutine and generator is that a coroutine can accept arguments

What are Scala continuations and why use them?

天涯浪子 提交于 2019-11-27 05:51:33
I just finished Programming in Scala , and I've been looking into the changes between Scala 2.7 and 2.8. The one that seems to be the most important is the continuations plugin, but I don't understand what it's useful for or how it works. I've seen that it's good for asynchronous I/O, but I haven't been able to find out why. Some of the more popular resources on the subject are these: Delimited continuations and Scala Goto in Scala A Taste of 2.8: Continuations Delimited Continuations Explained (in Scala) And this question on Stack Overflow: What are the biggest differences between Scala 2.8

Goto in Haskell: Can anyone explain this seemingly insane effect of continuation monad usage?

孤人 提交于 2019-11-27 05:10:52
问题 From this thread (Control.Monad.Cont fun, 2005), Tomasz Zielonka introduced a function (commented in a clear and nice manner by Thomas Jäger). Tomasz takes the argument (a function) of a callCC body and returns it for later usage with the following two definitions: import Control.Monad.Cont ... getCC :: MonadCont m => m (m a) getCC = callCC (\c -> let x = c x in return x) getCC' :: MonadCont m => a -> m (a, a -> m b) getCC' x0 = callCC (\c -> let f x = c (x, f) in return (x0, f)) Those are

What is call/cc?

我与影子孤独终老i 提交于 2019-11-27 05:07:16
问题 I've tried several times to grasp the concept of continuations and call/cc. Every single attempt was a failure. Can somebody please explain me these concepts, ideally with more realistic examples than these on Wikipedia or in other SO posts. I have background in web programming and OOP. I also understand 6502 assembly and had a minor randez-vous with Erlang. However still, I can't wrap my head around call/cc. 回答1: Look, i've found this Continuation Passing Style best description on this topic

Implementing yield (yield return) using Scala continuations

对着背影说爱祢 提交于 2019-11-27 03:04:05
How might one implement C# yield return using Scala continuations? I'd like to be able to write Scala Iterator s in the same style. A stab is in the comments on this Scala news post , but it doesn't work (tried using the Scala 2.8.0 beta). Answers in a related question suggest this is possible, but although I've been playing with delimited continuations for a while, I can't seem to exactly wrap my head around how to do this. Before we introduce continuations we need to build some infrastructure. Below is a trampoline that operates on Iteration objects. An iteration is a computation that can

Constructing efficient monad instances on `Set` (and other containers with constraints) using the continuation monad

主宰稳场 提交于 2019-11-27 01:09:30
问题 Set , similarly to [] has a perfectly defined monadic operations. The problem is that they require that the values satisfy Ord constraint, and so it's impossible to define return and >>= without any constraints. The same problem applies to many other data structures that require some kind of constraints on possible values. The standard trick (suggested to me in a haskell-cafe post) is to wrap Set into the continuation monad. ContT doesn't care if the underlying type functor has any