Purely stack-based generators

Norbert Nemec Norbert at Nemec-online.de
Fri Mar 19 02:32:49 PDT 2010


Walter Bright wrote:
> The trouble with a generator using the caller's stack is that then the 
> generator cannot recursively call itself (such as if it was walking a 
> tree). In order to work properly in the general case, a generator has to 
> allocate all its local variables on the heap.

Which concept of generators do you refer to? The stack-based generators 
that I suggested do in fact work recursively. A generator can obtain its 
values from other generators or even recursively from itself without 
needing heap space anywhere.



More information about the Digitalmars-d mailing list