D - most portable coroutine implementation (in C)
- nobody no.where Jan 18 2004
- Georg Wrede <Georg_member pathlink.com> Jan 18 2004
- nobody no.where Jan 18 2004
- Roel Mathys <roel.mathys yucom.be> Jan 20 2004
- "Sean L. Palmer" <palmer.sean verizon.net> Jan 21 2004
- Georg Wrede <Georg_member pathlink.com> Jan 21 2004
- "Sean L. Palmer" <palmer.sean verizon.net> Jan 22 2004
"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 of
back into the middle of a C routine (it uses a switch statement as a sort
computed goto). A good hack, and written in fully portable ANSI C." (from:
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..."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."
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 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 