[comp.sys.handhelds] Clean code

peraino@gmuvax2.gmu.edu (Bob Peraino) (01/26/91)

 
In article <25590090@hpcvra.cv.hp.com.> billw@hpcvra.cv.hp.com. (William C Wicke
   s) writes:
>I hate to complain about an otherwise nice program, but...
>
>Using CLEAR is a nasty thing to do to an unsuspecting 48.  IMHO, any
>program should be able to clean up after itself without trashing stack
>objects that it didn't put there.  And I shouldn't have to read a
>program's listing to figure out how to defend against its side
>effects.
>
>Bill Wickes
>HP Corvallis
 
     I wholeheartedly agree! The 48 is a VERY modular machine. Code
should ALWAYS leave the machine in the state it was before entering the
code. This goes beyond the stack; don't forget flags and variables.

peraino@gmuvax.gmu.edu

akcs.kevin@hpcvbbs.UUCP (Kevin Jessup) (01/27/91)

I agree!!  I wish more HP48SX programmers would use the PRESERVE program
that save flags, runs the application and then restores the flags.
I usually end up modifying the main routine of other peoples programs
to incorporate this function.  The program is described on page 555 od
the 48SX (Rev A) manuals.

PRESERVE
\<< RCLF
 \\-> f
\<< EVAL f STOF
\>>
\>>

Preserve will save the flags, evaluate the object on LEVEL 1 and
restore the flags.