sneaky message passing

sneaky message passing is about finding out-of-band channels for passing data between components.

errorInfo

PYK 2014-04-14: I added an object system to Functional imaging which uses $::errorInfo to bind methods to their instances. Perhaps this is a hideous thing to do, but in its first application, at least, it seems harmless enough.

PYK 2014-06-19: In do...until in Tcl, the tailcall variant needed to store the result and options from catch without polluting the caller's namespace, so used $::errorInfo and ::$errorCode for the purpose.

procedure rewriting

Braintwisters and other pages illustrate the art of rewriting procedures as an alternate way of passing information into the procedure.

interp alias

To maintain some state, an alias can be rewritten each time it is employed. Over on the closures page, _countMe uses this technique.

info coroutine

AMG: The Wibble web server arranges things such that the [info coroutine] command returns the name of the channel used to communicate with the client.

PYK 2014-06-19: I had seen that in Wibble. Nifty!

AMG: This avoids a ton of argument passing, and yet it avoids the pitfalls of global variables. Since [info coroutine] is now bytecoded, it may even be faster than a global too. Of course, this is a specialized circumstance and not likely to be applicable to just any old program.

namespace ensemble configure -map

Many object systems use the namespace ensemble map in their implementation, notably to pass the name of the command for the current object. Some small examples are Using namespace ensemble without a namespace and eos.

namespace ensemble configure -unknown

Data can be stashed in the -unknown, as a no-op argument in the list:

namespace ensemble create -unknown [list ::apply {{state args} {
}} {}]

To work with the data:

set unknown [namespace ensemble configure $namespace -unknown]
set state [lindex $unknown 2]
set unknown [lreplace $unknown 2 2 {}]
namespace ensemble configure $namespace -unknown $unknown
Do stuff with $state ...
set unknown [lreplace $unknown[set unknown {}] 2 2 $state]
namespace ensemble configure $namespace -unknown $unknown

On off-the-shelf way to use this facility is to use ycl shelf to transform a namespace into a shelf, and then use myshelf configure ..., where myshelf is the ensemble command of the namespace.

trace

trace is the quintessential out-of-band tool in Tcl.