If the current position points to a word, the various stepping commands behave as follows:
| • | com-step executes the word and moves the current position one word further. |
| • | com-into enters the word's definition, or its expansion if it is a macro. For a primitive it behaves like com-step. |
| • | com-out executes until the end of the current quotation. |
If the current position points to a literal, the various stepping commands behave as follows:
| • | com-step pushes the literal on the data stack. |
| • | com-into pushes the literal. If it is a quotation, a breakpoint is inserted at the beginning of the quotation, and if it is an array of quotations, a breakpoint is inserted at the beginning of each quotation element. |
| • | com-out executes until the end of the current quotation. |
The behavior of the
com-into command is useful when debugging code using combinators. Instead of stepping into the definition of a combinator, which may be quite complex, you can set a breakpoint on the quotation and continue. For example, suppose the following quotation is being walked:
{ 10 20 30 } [ 3 + . ] each
If the current position is on the quotation and
com-into is invoked, the following quotation is pushed on the stack:
[ break 3 + . ]
Invoking
com-continue will continue execution until the breakpoint is hit, which in this case happens immediately. The stack can then be inspected to verify that the first element of the array, 10, was pushed. Invoking
com-continue proceeds until the breakpoint is hit on the second iteration, at which time the top of the stack will contain the value 20. Invoking
com-continue a third time will proceed on to the final iteration where 30 is at the top of the stack. Invoking
com-continue again will end the walk of this code snippet, since no more iterations remain the quotation will never be called again and the breakpoint will not be hit.
On a fry form,
com-step fills the holes and pushes the resulting quotation.
com-into also inserts a breakpoint at its beginning, just as for a quotation literal. The body executes when the program calls the quotation. For example, step past the 3 and invoke Into on the fry in:
3 '[ 1 34 _ 5 + + ] call
Stepping over call then pauses before the first 1. Subsequent steps execute 1, 34, 3, 5, +, and +, leaving 1 and 42 on the data stack.
The
com-back command travels backwards through time, and restore stacks. This does not undo side effects (modifying array entries, writing to files, formatting the hard drive, etc) and therefore can only be used reliably on referentially transparent code.