behavior:header — ordinary primitive



BEHAVIOR ( xt1 -- xt2 )();


get the execution token xt2 that would be executed by the DEFER identified by xt1.

This command is used to obtain the execution contents of a deferred word. A typical use would be to retrieve and save the execution behavior of the deferred word, set the deferred word to a new behavior, and then later restore the old behavior.

If the deferred word identified by _xt1_ is associated with some other deferred word, _xt2_ is the execution token of that other deferred word. To retrieve the execution token of the word currently associated with that other deferred word, use the phrase BEHAVIOR BEHAVIOR .

Experience: Many years of use in OpenBoot and OpenFirmware systems. (Proposed for ANS Forth 2001)

In PFE it is the inverse of an IS operation and it will never fail if applied to a word with atleast a body. That's just like IS can be applied to almost every DOES> word where BEHAVIOR will get the value back.