next up previous contents index
Next: Rewinding Execution Up: Control Delimiters Previous: Control Delimiters   Contents   Index


Debugging

Another nice capability, from an incremental development and debugging viewpoint, is that with these tree-structured stacks, a thread of execution spun off of another thread immediately inherits the entire stack of its parent thread. This is done with no copying or other overhead. In actuality, the stack structure is the same for a subroutine call as it is for a thread spawning operation. The only difference is that a subroutine call waits for the subroutine to return before it proceeds, but the parent thread executes in parallel with the spawned thread.

Because of this structure, a breakpoint or other error can transfer control to a debugger, where the programmer can look at data and code, etc. The code can be edited to fix the problem. At this point, using a conventional Forth system, the programmer would have to reload the program and rerun it from the beginning, hoping that the problem did not recur. One of the advantages of Forth over other programming languages has always been the ease with which the programmer could do these steps, but if the program takes a very long time to run until it gets to the point of the error, a language that compiles slower but executes faster (such as C) would have an advantage.


next up previous contents index
Next: Rewinding Execution Up: Control Delimiters Previous: Control Delimiters   Contents   Index
Robert J. Brown
1999-09-26