The Debugging Process

Remove Debug Code for Non-debug Builds

You shouldn't distribute applications that contain Print statements. They slow your program down, they make your program larger, and programmers running your application with the Inspector open get annoyed by the extraneous output that spews forth.

Rely on the debugOn constant. It is true when you are doing a debug build, and nil otherwise (see "Compile for Debugging" on page 411 for information on how to do a debug build). You can restrict your Print statements to debug builds by using code like this:

non-debugging code
if debugOn then
   Print("got to point A in the program");
more non-debugging code
The Print statement will execute for a debug build, but will be stripped out of the compiled code for a non-debug build.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996