| Store | Cart

Re: [TCLCORE] Question on coroutines

From: Kevin Kenny <kevi...@gmail.com>
Mon, 07 Dec 2009 09:24:35 -0500
miguel sofer wrote: [quoting
http://www.inf.puc-rio.br/~roberto/docs/MCC15-04.pdf]:

> <cite>> The basic characteristic of symmetric coroutine facilities is the > provision of a single control-transfer operation that allows coroutines > to pass control explicitly among themselves. Marlin [1980] and Pauli and > Soffa [1980] argued that symmetric and asymmetric coroutines have no > equivalent power and that general coroutine facilities should provide > both constructs. However, it is easy to demonstrate that we can provide > any of these mechanisms using the other; therefore, no expressive power > is lost if only asymmetric coroutines are provided in a language.>     The implementation of symmetric coroutines on top of asymmetric > facilities is straightforward. Symmetrical transfers of control between > asymmetric coroutines can be easily simulated with pairs of yield–resume > operations and an auxiliary dispatching loop that acts as an > intermediary in the switch of control between the two coroutines. When a > coroutine wishes to transfer control, it yields to the dispatching loop, > which in turn resumes the coroutine that must be reactivated.> </cite>

At first, I found Miguel's terse explanation to be understandable
only at a "my brain hurts!" level.  Once I understood it, it looks
to be a cheap and elegant way to implement full-symmetric coroutines
without a dispatcher in the main routine.

The question that remains is whether this functionality is what we
want. As the Lua paper mentions, symmetric and asymmetric coroutines
are equivalent. (I believe that I read the Pauli and Soffa paper at
the time, and wondered why they asserted that they were not.) Since
[yieldto] is obviously a difficult concept to explain - a couple of
very smart people here were puzzled at first - the fact that comparable
functionality is easily done with existing facilities would seem to
argue against including it.

That said, the trick of having [yieldto] work by substituting the
call to the coroutine with another call is clever. And the fact that
the other call might be any other command, not just another coroutine,
might prove to be useful. (I can't imagine *how*, just at the moment,
but that's most likely a limitation of my imagination.) So I'm certainly
fine with experimenting with this in 'unsupported' and letting the
imaginative people see what they can make of it.

-- 
73 de ke9tv/2, Kevin

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

Recent Messages in this Thread
miguel sofer Dec 05, 2009 10:25 pm
Donal K. Fellows Dec 07, 2009 01:04 am
Kevin Kenny Dec 07, 2009 02:47 am
Larry McVoy Dec 07, 2009 02:56 am
Kevin Kenny Dec 07, 2009 04:41 am
Neil Madden Dec 07, 2009 09:35 am
miguel sofer Dec 07, 2009 01:41 pm
Kevin Kenny Dec 07, 2009 02:24 pm
Donal K. Fellows Dec 07, 2009 01:08 pm
miguel sofer Dec 07, 2009 01:20 pm
Donal K. Fellows Dec 07, 2009 02:09 pm
miguel sofer Dec 07, 2009 02:24 pm
miguel sofer Dec 07, 2009 04:44 pm
Neil Madden Dec 07, 2009 02:31 pm
Kevin Kenny Dec 07, 2009 02:44 pm
Neil Madden Dec 08, 2009 01:10 pm
Donald G Porter Dec 08, 2009 02:15 pm
miguel sofer Dec 08, 2009 02:22 pm
Kevin Kenny Dec 07, 2009 02:33 pm
Joe English Dec 08, 2009 06:08 pm
miguel sofer Dec 08, 2009 06:15 pm
Messages in this thread