| Store | Cart

Re: [TCLCORE] Question on coroutines

From: miguel sofer <migu...@gmail.com>
Tue, 08 Dec 2009 15:15:08 -0300
Joe English wrote:
> miguel sofer wrote:> >> The idea is that>>      yieldTo foo bar sum>> will:>>    1. suspend the currently running coro>>    2. cause the coro's caller to invoke [foo bar sum] in the place of>> the current coro, and take it's return value as the coro's return value>>>> IOW: it works EXACTLY like [tailcall] in the sense that the currently>> running thing is removed from the call stack and replaced by a new>> command. The difference is that where [tailcall] terminates the>> currently running proc, [yieldTo] suspends the currently running coro.> > OK, so if you have:> >     proc A {...} {> 	coroutine coro1 B ...>     }> > then in proc B:> >     yieldto C args...> > is the same as:> >     yield [C args...]> > except that:> >     (a) [uplevel 1] in the body of proc C will refer to proc A,>         not proc B; and:>     (b) C may call coro1.> > Do I have that right?

Yes. There are of course additional internal details in terms of stack 
consumption and suchlike, but irrelevant to the semantics.

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

Recent Messages in this Thread
Joe English Dec 08, 2009 06:08 pm
miguel sofer Dec 08, 2009 06:15 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
Messages in this thread