From:
Donal K. Fellows <dona...@manchester.ac.uk>
Thu, 18 Oct 2012 10:07:21 +0100
Hi everyone!
[This is related to a recent c.l.t thread on idioms for generating and
gathering coroutine results, in case you're wondering.]
If I have a coroutine and I want to make the code that invoked me do a
[break], how do I do this? (By "code that invoked me" I mean either the
code that called the [coroutine] command, or the code that called the
coroutine by name by way of resuming from a [yield].)
% proc all args {
yield [info coroutine]
foreach item $args {yield $item}
return -code break
}
% coroutine a all 1 3 5 7
::a
% while 1 {puts x=[a]}
x=1
x=3
x=5
x=7
invoked "break" outside of a loop
% set errorInfo
invoked "break" outside of a loop
while executing
"all 1 3 5 7"
invoked from within
"a"
% info patchlevel
8.6b3
I've tried a few other alternatives, but I've not found something which
can make that simple [while] terminate once all values have been
retrieved; what am I missing? (Or is this a bug?) My reading of TIP 396
and my memory of the (many many!) arguments around this area is that it
*ought* to work...
Donal (yes, I also want the coroutine to go away at that point, but
that's easy to arrange once I get the [break] out).
begin:vcard
fn:Donal K. Fellows
n:Fellows;Donal
org:The University of Manchester;Research Computing Services
adr:;;Oxford Road;Manchester;;M13 9PL;United Kingdom
email;internet:dona...@manchester.ac.uk
version:2.1
end:vcard
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Recent Messages in this Thread |
[TCLCORE] Coroutine puzzler |
Donal K. Fellows |
Oct 18, 2012 09:07 am |
|
Donal K. Fellows |
Oct 18, 2012 12:30 pm |
|
miguel sofer |
Oct 18, 2012 12:33 pm |
|
miguel sofer |
Oct 18, 2012 12:45 pm |
|
miguel sofer |
Oct 18, 2012 05:41 pm |
|
Donal K. Fellows |
Oct 18, 2012 11:31 pm |