Purely stack-based generators

Walter Bright newshound1 at digitalmars.com
Thu Mar 18 11:49:22 PDT 2010


Norbert Nemec wrote:
> Regan Heath wrote:
>> So, these generators are essentially inline functions?
> 
> No. They may be inlined, but this is just an optimization just like for 
>  regular functions. If they are not inlined, these generators are simply 
> functions with a special calling convention that allows them to retain 
> their local data and execution point on the stack in between calls.
> 
> I did work out the assembly code for this some time ago and it worked 
> nicely. Very similar to what is needed for co-routines, but it is 
> possible to do everything on the stack.

How is that different from a local delegate that refers to local variables of 
the function it is lexically nested in?



More information about the Digitalmars-d mailing list