Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!ucbvax!agate!shelby!portia.stanford.edu!elaine23.stanford.edu!mcgrant From: mcgrant@elaine23.stanford.edu (Michael Grant) Newsgroups: comp.sys.handhelds Subject: Re: Using CLEAR in progs (Was: Re: new puzzle, new blinky) Keywords: 48sx, CLEAR, programs Message-ID: <1991Jan26.221145.29164@portia.Stanford.EDU> Date: 26 Jan 91 22:11:45 GMT References: <25590090@hpcvra.cv.hp.com.> <56027@eerie.acsu.Buffalo.EDU> <19462@shlump.nac.dec.com> Sender: news@portia.Stanford.EDU (Mr News) Organization: Stanford University - AIR Lines: 36 In article <19462@shlump.nac.dec.com> ervin@pinbot.enet.dec.com (Joseph Ervin) writes: >>>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. I just thought of something that can replace CLEAR, work almost exactly LIKE clear (at least in what you WANT it to do), and yet save everyone's stack so that when they exited the progam everything was cool. It's certainly not original (it's used in postscript implementation), but noone's mentioned it here...it's 'clear to mark'. Just put some unique object onto the stack at the beginning of your program--one that you never use otherwise--and then at the end of the program, just execute this 'clear to mark' program: CTOM << WHILE SAME NOT DO END >> Now, I have no idea if the syntax is correct, because I rarely use the WHILE command (if it exists). But, I think you get the idea: drop everything up to and including the mark. It's a simple program that you can include in your HOME directory or in the directory that your super-awesome-new-package-that-you- will-be-announcing-and-releasing-real-soon is kept. I hope this helps anyone who hates leaving extry stuff on the stack! Michael C. Grant