foreach vs. iterators

Walter Bright newshound at digitalmars.com
Fri Nov 3 22:11:46 PST 2006


Bill Baxter wrote:
> Now whether or not coroutines are realistically implementable in a 
> systems programming language like D is beyond me.  Stackless Python 
> folks did it, but perhaps they're taking advantage of the fact that 
> users of interpreted code are a bit more forgiving about runtime 
> overhead, and the fact that the interpreter has its own notion of the 
> stack that doesn't depend on low-level processor details like EAX 
> registers etc.  But technically I don't see any roadblocks.  I mean I 
> read somewhere that coroutines are an old assembly programming trick, so 
> the hardware is certainly capable of supporting the paradigm at the low 
> level.  It's basically just a jmp plus a manipulation of the stack 
> pointer when it comes right down to it.

It's not so easy to implement in the general case (asm code takes 
advantage of special, easy cases). To make it work, you need to allocate 
the stack frame of the coroutine on the heap. Not impossible, but a lot 
of work involved.



More information about the Digitalmars-d-announce mailing list