inject

tcl::unsupported::inject coroName cmd ?arg1 arg2 ...?

AMG: What is this new command? This [1 ] appears to be the initial check-in, which says that it takes arguments [::tcl::unsupported::inject coroname command args] and makes the named command be the first thing the coroutine does the next time it's resumed.

DKF: It's supposed to be a mechanism for introducing a command into a coroutine that allows for things like debugging. It is, however, considered rather too difficult to use (or explain the exact semantics of) in its current incarnation.

APN: Interactive example:

% coroutine mycoro apply {{} { while {1} {puts "Hoo ha" ; yield} }}
Hoo ha
% mycoro
Hoo ha
% tcl::unsupported::inject mycoro puts Injected!
% mycoro
Injected!
Hoo ha
% mycoro
Hoo ha
% tcl::unsupported::inject mycoro return Done!
% mycoro
Done!
% mycoro
invalid command name "mycoro"

Napier: (2016-10-16) I have been using this command quite a bit and have posted various uses of it. You can view one such use in the every page towards the bottom. In the example the inject command is utilized to pause or cancel the every routines that are created. This helps provide these features in a much more efficient way then was being done previously as it does not require using namespace variables for things like Pause, Resume, and Cancellation. Personally I find it a pleasure to work with and simple enough to understand. It provides a mechanism for building some interesting control structures when working with coroutines.