Post Reply 
INPUT stack lift: 32S vs. 42S
10-11-2019, 05:12 PM
Post: #5
RE: INPUT stack lift: 32S vs. 42S
(10-11-2019 04:20 PM)ijabbott Wrote:  I guess a program shouldn't really trust anything on the stack apart from X after halting for input. The user may have done some calculations (buggering up the old stack contents) before pressing R/S to continue.

This ^

I never rely on anything in the stack when one of my RPN programs stops for input or output. Doing otherwise means that your code ceases to be deterministic and is left in a random state if the user alters the stack while the program is stopped, thus you can't be sure what will happen once it resumes execution. Relying on stack contents while a programs is stopped is a truly bad programming practice and one the the biggest no-no in any programming book, not just mine.

Also, that's one of the strongest advantages the (SHARP, HP-71B and others) BASIC-programmabkle pocket computers had over any RPN model: you could stop the running program at most any time, do from the command line whatever manual calculations or operations you needed (of course, as long as you didn't execute commands that disrupted the program flow or program variables) and once done, simply execute CONT to resume program execution as if no interruption had ever happened.

Try that with an RPN program ! (probably RPL too, unless you do something to first back up/restore the whole stack or things like that).

Have a nice weekend.
V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: INPUT stack lift: 32S vs. 42S - Valentin Albillo - 10-11-2019 05:12 PM



User(s) browsing this thread: 1 Guest(s)