D - most portable coroutine implementation (in C)
- nobody no.where (7/7) Jan 18 2004 "The most portable coroutine solution I have seen in C is at
- Georg Wrede (3/3) Jan 18 2004 If you weren't the same guy who posted about Stackless Python,
- nobody no.where (2/5) Jan 18 2004 Collect all the info, and let Walter decide :-)
- Roel Mathys (36/36) Jan 20 2004 nice thingies,
- Sean L. Palmer (9/15) Jan 21 2004 Looks like finally a legitimate use of the __LINE__ macro besides
- Georg Wrede (7/16) Jan 21 2004 Maybe we should try to figure out what the absolute minimum hacking
- Sean L. Palmer (4/14) Jan 22 2004 His iterator stuff, opApply, is getting really close.
"The most portable coroutine solution I have seen in C is at http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html and relies on the infamous "Duff's device" in order to do its magic of jumping back into the middle of a C routine (it uses a switch statement as a sort of computed goto). A good hack, and written in fully portable ANSI C." (from: http://nebuladevice.sourceforge.net/cgi-bin/twiki/view/Nebula/FiberMicrothread)
Jan 18 2004
If you weren't the same guy who posted about Stackless Python, I would've jumped on the table. Now, I have to ask you, what's your agenda?
Jan 18 2004
In article <buf189$1krd$1 digitaldaemon.com>, Georg Wrede says...If you weren't the same guy who posted about Stackless Python, I would've jumped on the table. Now, I have to ask you, what's your agenda?Collect all the info, and let Walter decide :-)
Jan 18 2004
nice thingies,
played a bit in D with it (see code below).
btw in Python you do have the keyword "yield" - used for generators -
which does stuff like this, there you can do something like this:
for x in array:
doit(x)
after the last occurrence an exception is thrown (I believe),
this exception indicates that the iteration is finished.
bye,
roel
=============================================
char[uint] enumerate( char[] s )
{
static uint state = 0;
static uint index = 0;
char[uint] ti;
switch (state)
{
case 0:
for ( ; index<s.length; ++index )
{
state = 1;
ti[index] = s[index];
return ti;
case 1:
}
return ti;
}
}
void main()
{
char[] s = "hello";
char[uint] ci;
while ( cast(bool)(ci = enumerate(s)))
printf( "%d -> %c\n", ci.keys[0],ci.values[0]);
}
Jan 20 2004
Looks like finally a legitimate use of the __LINE__ macro besides cross-compilation and leak tracking. This is why language support is so important for coroutines/fibers/whatever you call them. Sean <nobody no.where> wrote in message news:buessj$1dg1$1 digitaldaemon.com..."The most portable coroutine solution I have seen in C is at http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html and relies on the infamous "Duff's device" in order to do its magic ofjumpingback into the middle of a C routine (it uses a switch statement as a sortofcomputed goto). A good hack, and written in fully portable ANSI C." (from:http://nebuladevice.sourceforge.net/cgi-bin/twiki/view/Nebula/FiberMicrothread)
Jan 21 2004
In article <bule3p$2sjc$1 digitaldaemon.com>, Sean L. Palmer says...This is why language support is so important for coroutines/fibers/whatever you call them. <nobody no.where> wrote in message news:buessj$1dg1$1 digitaldaemon.com...Maybe we should try to figure out what the absolute minimum hacking by Walter would be, that enables us to implement help for this in D? I don't mean anything final and fancy, or perfect, just the minimum so that one can implement this particular solution in D with less brittle results and somewhat less coding. I may have some ideas, but they're still just embryonic."The most portable coroutine solution I have seen in C is at http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html and relies on the infamous "Duff's device" in order to do its magic of jumping back into the middle of a C routine (it uses a switch statement as a sort of computed goto). A good hack, and written in fully portable ANSI C."
Jan 21 2004
His iterator stuff, opApply, is getting really close. Sean "Georg Wrede" <Georg_member pathlink.com> wrote in message news:bulluv$6tj$1 digitaldaemon.com...In article <bule3p$2sjc$1 digitaldaemon.com>, Sean L. Palmer says...This is why language support is so important for coroutines/fibers/whatever you call them.Maybe we should try to figure out what the absolute minimum hacking by Walter would be, that enables us to implement help for this in D? I don't mean anything final and fancy, or perfect, just the minimum so that one can implement this particular solution in D with less brittle results and somewhat less coding. I may have some ideas, but they're still just embryonic.
Jan 22 2004









nobody no.where 