Generators in D

Piotr Szturmaj bncrbme at jadamspam.pl
Tue May 17 14:37:53 PDT 2011


Sean Kelly wrote:
> On May 11, 2011, at 3:06 PM, Piotr Szturmaj wrote:
>
>> Andrei Alexandrescu wrote:
>>> * can you implement save() to make this a forward range (e.g. by
>>> creating a new fiber that has its own state)?
>>
>> It is not that simple I guess. Fiber class doesn't give any opportunity to save
 >> current stack and I think it might be wrong to do this, because of 
GC issues.
 >> But I don't certainly know.
>>
>> I think that author of the Fiber class could answer this better than me.
>> If Fiber will expose some additional API, then I would certainly implement save().
>
> Cloning a Fiber would essentially produce a shallow copy--if the Fiber's stack contains
 > references to data elsewhere on the same stack, the clone's stack > 
would reference the original's.  So while this could be done,
 > I don't think it's advisable.

But couldn't Fiber's stack be scanned for references to itself and 
readjusted?


More information about the Digitalmars-d mailing list