Next: Step By Step Imperative Program Execution Example, Up: Step By Step Imperative Program Execution
There are quite a few reasons for which an application might want to execute programs instruction by instruction. Obvious ones would include execution length (duration that is) limitation. The application would count instructions as they are executed and when it decides they just got too many it may abort (simply stop) executing program.
There are other, less obvious reasons for which an application might want to execute programs instruction by instruction. Such reasons would include temporaries disposal and execution weaving.
Consider an application that needs to provide functions that allocate resources that have no use but the immediate one. Like for an instance the formatted representation of some data needing display. One might like to write:
display(format(data));
In such instance, the `format' function will likely allocate some space for the formatted representation of `data'. Such formatted representation is of no use as soon as `display' completes execution. Call the formatted representation a temporary since it is not recorded with the program data. Call the deallocation of such temporary resources temporaries disposal.
The applications providing for functions creating temporaries will like to free the allocated resource as soon as possible. By recording the temporaries with some immediate deallocation mechanism and executing programs step by step, the interested applications will be provided with the required temporaries disposal opportunity.
See Temporaries.
Applications interested in executing programs for some time, reverting to their other activities and than back to program execution will also be benefited by step by step program execution.
Consider again an application that allows programs to request actions to be performed. For the simpler tasks the immediate execution in the very function call that requested them would be most appropriate. For complex tasks the application may like to leave to program execution logic (maybe because the application likes to tend as well to other activities, activities like polling I/O channels, checking scheduled tasks and so forth). Once the program requested tasks are carried out, the application may resume program execution. Call such switching between program execution logic and application internal logic execution weaving. The step by step program execution provides for execution weaving as well.