I'm working on a Scheme interpreter written in C. Currently it uses the C runtime stack as its own stack, which is presenting a minor problem with implementing continuations. My current solution is manual copying of the C stack to the heap then copying it back when needed. Aside from not being standard C, this solution is hardly ideal.
...
I'm trying to grasp the concept of continuations and I found several small teaching examples like this one from the Wikipedia article:
(define the-continuation #f)
(define (test)
(let ((i 0))
; call/cc calls its first function argument, passing
; a continuation variable representing this point in
; the program as the arg...
What are they and what are they good for?
I do not have a CS degree and my background is VB6 -> ASP -> ASP.NET/C#. Can anyone explain it in a clear and concise manner?
...
Has anyone ever done work to get Ruby to do continuations (like Seaside on Smalltalk)?
...
How do I get a BlockClosure in Squeak (I want to use BlockClosure>>callCC)?
When I write [#foo] that is a BlockContext, what's the deal?
Update: I have worked out that BlockClosure is a thing mainly of new compiler.
Instead how do I work with seaside Continuations? I'm having problems, and any examples would be appreciated.
Further u...
Some APIs, like the WebClient, use the Event-based Async pattern. While this looks simple, and probably works well in a loosely coupled app (say, BackgroundWorker in a UI), it doesn't chain together very well.
For instance, here's a program that's multithreaded so the async work doesn't block. (Imagine this is going in a server app and...
I'm looking for a fast language (ie. a language that can be compiled natively to achieve performance not more than 3 or 4 times slower than C), which supports portable continuations. By this I mean a continuation that can be serialized on one computer, and deserialized on another.
I know that SISC can do this (a Scheme implementation i...
What is the Python equivalent of the following code in Ruby?
def loop
cont=nil
for i in 1..4
puts i
callcc {|continuation| cont=continuation} if i==2
end
return cont
end
> c=loop
1
2
3
4
> c.call
3
4
Reference: Secrets of lightweight development success, Part 9: Continuations-based frameworks
...
I'm considering something like CPS for use in an interpreter for an actor based language.
The function arguments are passed in an array of variants, and the continuation returned in the same array, so an simple function
def add (x,y) => x + y
so a call from the read/eval/loop would be
print( add(7, 5) )
would on entry be
[&add, x...
Is it possible to programmatically construct a stack (one or more stack frames) in CPython and start execution at an arbitrary code point? Imagine the following scenario:
You have a workflow engine where workflows can be scripted in Python with some constructs (e.g. branching, waiting/joining) that are calls to the workflow engine.
A ...
If I have a statement in Ruby that I want to continue on the next line, normally I would add a backslash at the end of the line like this:
print x \
+ y
But if I have comments on the line, it doesn't work:
print x #show x
+ y # show y
Is there a way around this?
(Edit: Squeegy's solution is correct and, actually, I knew you could...
I'm making a framework for specifying processes which may involve choices. I've got it working where each choice is an island. I'd prefer that subchoices 'fork' the parent choice, so that all options are properly considered.
choose :one => lambda {
choose [a, b]
if a
raise "Illegal"
end
},
:two => ....
Currently...
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 ra...
Can continuations be said to be monads? Are they a subset of monads or are they simply a way of implementing monads?
Edit: Or maybe I got it wrong and monads is a more abstract concept than continuations? (So I'm really comparing apples to oranges here)
...
I have a Seam application that kicks off business processes. At the moment there is no other application or component that needs to co-ordinate, there is just the one web app.
I'd like to use asynchronous continuations in the business processes, but at the moment if I do the process just sits there inactive and the relevant actions are ...
What is the difference between a coroutine and a continuation and a generator ?
...
So I believe I understand continuations now, at least on some level, thanks to the community scheme wiki and Learn Scheme in Fixnum Days.
But I'd like more practice -- that is, more example code I can work through in my head (preferably contrived, so there's not extraneous stuff to distract from the concept).
Specifically, I'd like to ...
I'm struggling to understand the concept of Continuations (as used in Seaside with Smalltalk). A snippet from Wikipedia says:
"... refer to first-class continuations, which are constructs that give a programming language the ability to save the execution state at any point and return to that point at a later point in the program..."...
Is there any way of turning off Line Continuation in VB.net? I want to be able to prevent VS 2008 from automatically editing any long strings so they use line continuation. I would far rather have it all on one line even if i cannot see the entire screen. Any solutions guys?
Thanks in advance!
...
I've written a small Scheme interpreter in C#, and realised that the way I had implemented it, it was very easy to add support for proper continuations.
So I added them... but want to "prove" that they way that I've added them is correct.
My Scheme interpreter however has no support for "mutating" state - everything is immutable.
So i...