Stackless resumable functions

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 23 19:22:10 PST 2015


On Tuesday, 24 February 2015 at 00:48:34 UTC, ketmar wrote:
> On Mon, 23 Feb 2015 23:10:28 +0000, bitwise wrote:

> you still thinking in terms of generators. Generator is a 
> high-level construct, resumable routine is a low-level 
> construct. latter is used to build the former.

I think you're getting confused between "stackless" and 
"stackful" resumable functions.
If I wanted stackful resumable functions, I would just use D's 
Fiber. If I wanted something lower level, I would simply make a D 
wrapper for boost::fcontext.

http://www.boost.org/doc/libs/1_57_0/boost/context/fcontext.hpp

#define RF "resumable function"  //  :)

But, I am not talking about stackful RF. The control flow you're 
describing is that of a stackful RF. With stackless RFs, you 
can't just randomly switch control flow between coroutines, nor 
can you yield from nested stack frames. A stackless RF runs on 
the same stack as everything else. Only the local variables and 
RF's arguments are allocated on the heap.

That said, I can't think of a lower level abstraction than what I 
have provided that would actually be useful...


> i don't even want to know what boost does. it stinks anyway.

Maybe this is why you don't get what I'm saying ;)


> anywhere. any code. any delegate usage. it's a simple idiom of 
> "switching control", where "function that calling delegate" can 
> be seen as "delegate that calling the function".

Again, I'm pretty sure you're thinking of stackful RFs.



> it's like building the brick house without having the bricks.

Don't be silly, we're clearly building a bike shed here.


More information about the Digitalmars-d mailing list