next up previous contents index
Next: Multitasking Up: Other Threading Techniques Previous: Trampolines   Contents   Index


Repackaging

The direct threading technique in the example exhibits no extra overhead during execution, but it has one shortcoming: a word may only be rebound to another word of the same type. This means colon definitions may only be rebound to other colon definitions; variables may only be rebound to other variables. Code words may not be re-bound at all. This makes it difficult to use before and after methods to place demons at watch over a variable, because the demons are colon definitions, and the variable may not be bound to colon definitions. These demons are necessary in order to implement active values. (Active values are variables that produce some extra action when they are referenced.) The kludge solution is to wrap the variable up as a colon definition that looks like:


  VARIABLE my-var            \ define the variable
         : my-var my-var ;   \ repackage as colon definition

which solves the problem in a way similar to the repackaging approach described for indirect threading above.

Both the direct and indirect threading implementations of Dreams produce an approximation to the ideal behavior. Indirect threading implementations will introduce extra overhead with every subroutine call. Direct threading implementations are restrictive in the kinds of rebinding that may be done: a word may only be rebound to the action associated with another word of the same kind, and code words may not be rebound at all. It is desirable to be able to rebind any word to any other word without regard to its type.


next up previous contents index
Next: Multitasking Up: Other Threading Techniques Previous: Trampolines   Contents   Index
Robert J. Brown
1999-09-26