Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!csn!spot.Colorado.EDU!frechett From: frechett@spot.Colorado.EDU (-=Runaway Daemon=-) Newsgroups: comp.sys.handhelds Subject: Re: CLEARing stack Keywords: CLEAR Message-ID: <1991Jan29.044750.1789@csn.org> Date: 29 Jan 91 04:47:50 GMT References: <10535@jarthur.Claremont.EDU> Sender: news@csn.org (news) Organization: University of Colorado, Boulder Lines: 58 Nntp-Posting-Host: spot.colorado.edu In article <10535@jarthur.Claremont.EDU> sburke@jarthur.Claremont.EDU (Scott Burke) writes: >Here are some more thoughts on stack clearing. >hit on the solution I have found to work acceptably: to use a stack depth >counter and then upon exiting the program, restore the correct depth of the >stack. This simply changes the headache, however, because now the code has Ummm excuse me if this sounds too simple but why do you need a stack counter that keeps track of additions and subtractions from the stack.? >Scott. >sburke@jarthur.claremont.edu Let me work this out. If start the program with DEPTH -> STKdpth at ANY point in the program, I could kill everything but that original stuff with a routine like this.. Here is a sample program that I just tried out. \<< DEPTH \-> STKdpth \<< HALT DEPTH STKdpth DROPN \>> \>> When executed it stops at HALT.. I can do anything that I damn well please to the stack short of killing the original stuff that was on the stack.. for my test I had. 4: 4 3: 3 2: 2 1: 1 and when it halted, I entered as much crap as I could stand to add to the stack. Performed Calculations etc.. then hit CONT and poof the only thing left on the stack was. 4: 4 3: 3 2: 2 1: 1 I can't think of ANYTHING simpler than this.. If you have a program that tends to devour stuff that was previously on the stack then I pity your program.. If it is supposed to eat some arguments then it is a simple matter to subtract 1 or 2 from STKdpth. I just am not sure what you meant by having all this keeping track of stack stuff. Take the example you gave of EDIT and the ^STK function. Let's say I was going to write EDIT with my routines... I might define the ^STK function as something like \<< DEPTH STKdpth ->LIST @puts any current program stuff in a list. -> Temp.shit @Put list in local Var. Who cares if it dies. LOOKATSTACK_ROUTINE @the catalog like thing that ^STK does. Temp.shit LIST-> ROLL @Bet we will deal with ECHOed stuff next. \>> Give me an example where this wouldn't screw up other than HUNGRY programs or of course ones that use CLEAR.. ;) ian -- -=Runaway Daemon=-