Why Use a Stack?

Why use a stack in an application? You might want to track forms as a user opens them and then be able to back out of the open forms in the opposite order: That is, you may want to store form references in the stack and then, as the user clicks the OK button on each form, bring the correct form to the top, popping the most recent form from the stack. Or you may want to track the procedure call tree within your application, as your user runs it. That way, you could push the name of the procedure as you enter the procedure. On the way out, you could pop the stack. This way, the top of the stack always contains the name of the current procedure. This value is, otherwise, impossible to retrieve. You could also build your own application profiler. By storing the current time in the stack for each procedure as you push it on the stack and then subtracting that from the current time as you pop the stack, you can find out how long the code was working in each procedure.

© 1997 by SYBEX Inc. All rights reserved.