Norbert Nemec wrote:
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.

How can it do that, and yet allow the calling function also call other 
functions?

Reply via email to