Continuations in D?

pragma pragma_member at pathlink.com
Wed Feb 22 10:38:31 PST 2006


In article <dthuue$297c$1 at digitaldaemon.com>, Brad Anderson says...
>
>Brad Anderson wrote:
>> Good stuff here: http://en.wikipedia.org/wiki/Continuation
>
>and following one of the links from the above page, this was great for C 
>programmers:
>
>http://www.intertwingly.net/blog/2005/04/13/Continuations-for-Curmudgeons
>
>BA

I'd love to see something like that get off the ground, especially for
web-programming.  From what I understand, a true continuation needs to be
context-switchable which is to say it can save/restore register and stack info. 

Win32 Fibers already provide nuts and bolts for this capability, and I think
unix/linux has an analgoue of the same.  So a wrapper using what the OS
provides, for something like this, could be hashed up without too much fuss. 

It might also be possible to concoct something in D, that uses some ASM to
handle saving and restoring the stack state.  You'd almost want this solution as
it would invariably involve less kernel time and could lend itself to tighter
resource management (key for scalable web apps that could have more than one
such continuation per user session).

With all of the above approaches, you still won't have a syntax as elegant as
what Python has.  D would need a 'yield' statement and/or something that flags a
function/delegate as having its own discrete stack space.

As for hacking it into DSP, it's more a factor of "when we get there" than
anything else. :)

- Eric Anderton at yahoo



More information about the Digitalmars-d mailing list