Posted to tcl by dgp at Fri Aug 13 16:38:55 GMT 2010view pretty

% coroutine make apply {{} {
    yield
    set l {1 2 3}
    foreach e $l {
        take $e
    }
    return -code error done
}}
% coroutine take apply {{} {
    while {[catch make val] == 0} {
        puts $val
    }
puts ERROR:$val
}}
ERROR:coroutine "take" is already running
% set errorInfo
coroutine "take" is already running
    while executing
"take $e"
    (lambda term "{} {
    yield
    set l {1 2 3}
    foreach e $l {
        ..." line 5)
    invoked from within
"apply {{} {
    yield
    set l {1 2 3}
    foreach e $l {
        take $e
    }
    return -code error done
}}"
    invoked from within
"make"