Path: utzoo!utgpu!watserv1!watmath!att!pacbell.com!ucsd!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!shlump.nac.dec.com!pinbot.enet.dec.com!ervin From: ervin@pinbot.enet.dec.com (Joseph Ervin) Newsgroups: comp.sys.handhelds Subject: Re: Using CLEAR in progs (Was: Re: new puzzle, new blinky) Keywords: 48sx, CLEAR, programs Message-ID: <19462@shlump.nac.dec.com> Date: 25 Jan 91 19:46:25 GMT References: <1991Jan10.172803.2262@DRD.Com> <25590090@hpcvra.cv.hp.com.> <56027@eerie.acsu.Buffalo.EDU> Sender: newsdaemon@shlump.nac.dec.com Reply-To: ervin@pinbot.enet.dec.com (Joseph Ervin) Organization: Digital Equipment Corporation Lines: 39 >>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. > >I would point out that I just saw another program here that uses >CLEAR, even to the point of excessiveness. Different discussion >thread, though. Hmm.... I just checked my Phone Number manager program and noticed that I use CLEAR in a pile of places. Apparently this is considered poort programming practice. I must agree. It seems that a simple approach to solve this problem in my Phone Number Manager would be to collapse the stack into a list upon entry of the program and save it in a temporary variable. Then at exit time, just restore the contents to the stack. This would avoid having to rewrite the routines that use CLEAR. On the other hand, it probably isn't necessary to use CLEAR at all and that the program would run fine without them. I think I just put them in by habit ( as in "it's nice to know the stack is empty upon entering a routine, so if my code is buggy it'll be easier to debug because I'll run out of operands, rather than performing operations on 'old and unrelated data' that was left on the stack"). I will put this on my list of things for the next version. Regards, >>>Joe Ervin P.S. Whoever puts my phone number manager on the goodies disk had better make sure he/she didn't copy the "garbled" V1.4 I first posted. I have since posted a corrected V1.4 which works. The "garbled" one won't even download properly to the 48SX.