Stackless resumable functions

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 23 16:48:34 PST 2015


On Mon, 23 Feb 2015 23:10:28 +0000, bitwise wrote:

>> you don't need to. if you really need to do that, you're doing
>> something
> 
> This makes no sense to me. A usage example may be helpful.

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.

>> resumable functions are not iterators. it's a slightly perversed flow
>> control method. iteration/generation is one of the use cases.
> 
> So how do you explain enumerators in C#, or generators in visual c++?

as one of the possible high-level constructs that can be built with 
resumable routines.

> http://www.boost.org/doc/libs/1_57_0/libs/coroutine/doc/html/index.html
> 
> [quote]
> Coroutine
>      Asymmetric coroutine Symmetric coroutine
> [/quote]

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

>> mimicking delegates allows to use resumable function in any code that
>> expects delegate.
> 
> If you can come up with even one example(with code) where it would make
> sense to accept both coroutines and delegates, I will be very surprised.

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". heh. anytime you need to switch the 
controlling side without rewriting the code. if you can't think out the 
use case for this, you still looking at resumable routines from the wrong 
POV.

> In any case, I have revised my design. Generator(T) was redundant, so I
> removed it. Below is something that I think is well formed enough for me
> to start digging through the compiler for specifics.

it's like building the brick house without having the bricks. you trying 
to build the house when you have to make bricks. sure, you can do that... 
and than cursing while smashing it into bricks when you need to build the 
fence. or building fences from houses.

what you *really* trying to do is to build specific actor instead of 
building the foundation for programming with actors. building the 
foundation for actor model is way better and will allow you to build your 
generators easily.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150224/bfc2a551/attachment.sig>


More information about the Digitalmars-d mailing list