continuations

Which way is best, to implement Comets in a Java Servlet

I want to write an aplication that uses the Comets pattern - that is a request that can be responded to when an event occurs on the server, rather than only as a response to an immediate request. What is the easiest application server to use for this purpose, is it: 1) Tomcat with its NIO package 2) Jetty with its continutations 3) or...

Non-determinstic choice with amb-operator

Is it possible to implement McCarthy's amb-operator for non-deterministic choice in C#? Apparently .NET lacks continuation support but yield return could be useful. Would this be possible in other static .NET-languages like F#? ...

Specifics of call/cc

This is related to http://stackoverflow.com/questions/612761/what-is-call-cc, but I didn't want to hijack this question for my own purposes, and some of its arguments like the analogy to setjmp/longjmp evade me. I think I have a sufficient idea about what a continuation is, I think of it as a snapshot of the current call stack. I don't ...

Continuations in Clojure.

I read somewhere where rich hickey said: "I think continuations might be neat in theory, but not in practice" I am not familiar with clojure. 1. Does clojure have continuations? 2. If no, dont you need continuations? I have seen a lot of good examples especially from this guy. What is the alternative? 3. If yes, is there a docu...

What are "Jetty 6 Continuations" and how do they compare to the continuations found in programming languages?

I'm looking for an answer that describes a "continuataion' mechanism in a web server vs. a programming language. My understanding is that using continuations, it is trivial to have a "digits of pi" producer communicate with a "digits of pi" consumer, without explicit threading. I've heard very good things about Jetty continuations, cur...

Methods for side-effects in purely functional programming languages

At the moment I'm aware of the following methods to integrate side-effects into purely functional programming languages: effect systems continuations unique types monads Monads are often cited to be the most effective and most general way to do this. Which other methods exist? How do they compare? ...

Design Pattern Alternative to Coroutines

Hi, Currently, I have a large number of C# computations (method calls) residing in a queue that will be run sequentially. Each computation will use some high-latency service (network, disk...). I was going to use Mono coroutines to allow the next computation in the computation queue to continue while a previous computation is waiting f...

Mono Continuations - Memory keeps increasing after store()

Hi, Here's Mono Continuations' continuation_store (...). From looking at the code below, it appears as though store() follows these two branches: cont->saved_stack && num_bytes <= cont->stack_alloc_size use the memory directly else gc free the used memory, and create some new memory. However, the weird thing is if I repeatedly ...

Continuations in Java

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? ...

Cons of first class continuations

What are some of the criticisms leveled against exposing continuations as first class objects? I feel that it is good to have first class continuations. It allow complete control over the execution flow of instructions. Advanced programmers can develop intuitive solutions to certain kind of problems. For instance, continuations are used...

What are Scala continuations and why use them?

So 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 its useful for or how it works. I've seen that 'its good for async I/O' but I haven't been able to find out why. Some of the mor...

How does PLTScheme Catch errors?

I am amazed by the "error" function in PLTScheme. If I have a division by zero, it doesnt do any other recursion and just comes out of the call stack and give me an error. Is there an implicit continuation before all the functions? Does the error throw away the call stack? Does anybody have any idea about this? ...

Javascript CPS (continuation passing style) implementation

Because of an article in IBM Developer Works about CPS (continuation passing style), I'm trying to not use "return". without CPS function getter() { * calculate a* return a; } function test() { *part 1* if(*condition*) { a = getter(); } *use a* *part 2* } transition the rest of the function ...

Can somebody please explain this continuation in scheme?

I am learning continuations but I can't wrap my head around this code. Why does it go into infinite loop? (let ((cont #f)) (call/cc (lambda (k) (set! cont k))) (cont #f)) ...

Can I have a co-routine of three functions using continuations in Scheme?

Is it possible to add another function procC in here so that the sequence of evaluation is procA->procB->procC->procA ... ? (define (procA another-fun) (let loop ((n 5)) (display "In Proc A \n") (set! another-fun (call/cc another-fun)) (when (> n 0) (loop (- n 1))))) (define (procB another-fun) (let loop ((n 5)) ...

Help understanding Continuations in Scheme

I have been working alongside The Little Schemer to learn Scheme and using PLT-Scheme for my environment. The Little Schemer has helped me tremendously with recursion (it is straightforward for me now) but I'm stuck on a portion of the book that introduces "collectors" and calls the function as a whole a continuation. Here is the examp...

What exactly are administrative redexes after CPS conversion?

In the context of Scheme and CPS conversion, I'm having a little trouble deciding what administrative redexes (lambdas) exactly are: all the lambda expressions that are introduced by the CPS conversion only the lambda expressions that are introduced by the CPS conversion but you wouldn't have written if you did the conversion "by hand"...

Implementing yield (yield return) using Scala continuations

How might one implement C# yield return using Scala continuations? I'd like to be able to write Scala Iterators 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...

Detect client has disconnected from jetty server (using continuations)

Hi all, I am using jetty continuations and I was wondering if I can detect that the client has disconnected(closed connection to jetty server) from the server. Thanks, Alfred ...

Scheme early "short circuit return"?

I'm trying to find out how I can do an "early return" in a scheme procedure without using a top-level if or cond like construct. (define (win b) (let* ((test (first (first b))) (result (every (lambda (i) (= (list-ref (list-ref b i) i) test)) (enumerate (length b))))) (when (and (not (= test 0)) result) ...