sneaky message passing
is about finding out-of-band channels for passing data between components.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
for the purpose.
procedure rewriting editBraintwisters
and other pages illustrate the art of rewriting procedures as an alternate way of passing information into the procedure.
To maintain some state, an alias can be rewritten each time it is employed. Over on the closures
uses this technique.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 bytecode
d, 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.
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
is the quintessential out-of-band tool in Tcl.