Generators in D

Piotr Szturmaj bncrbme at jadamspam.pl
Wed May 18 08:00:39 PDT 2011


Sean Kelly wrote:
> On May 17, 2011, at 2:37 PM, Piotr Szturmaj wrote:
>
>> 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?
>
> Without type information, there's no way to be sure that something is actually a reference, so corruption could occur.

Then, how GC scan Fiber's stack for references? I thought some portion 
of GC code could be used for this.


More information about the Digitalmars-d mailing list