Post Reply 
RPL programming questions
02-17-2014, 01:54 PM
Post: #1
RPL programming questions
I'm getting to know RPL on an HP 48. I've done a lot of programming on the older so-called "keystroke" programmable models from HP and even TI and it's pretty simple compared to RPL. I've been trying to read everything I can find on the net about RPL and it seems like the general recommendation is to avoid local variables. That works fine on small programs but it gets tricky on programs with a lot of calculations and intermediate variables.

I looked at some information on Forth since there is more Forth doc out there than HP RPL doc and I understand you're supposed to factor problems into meaningful "words" (RPL commands). I can see how to do that when the calculations that make up a bigger problem are meaningful by themselves and can be reused. What I don't get is what to do when you have a big set of calculations and a lot of intermediate values that don't have any value from a reuse point of view.

To actually work through a big problem the simple solution seems to be to pick a letter for each temporary and save the calculation as a letter. Do that for all the calculations in the problem and then to write a classically-correct RPL solution that doesn't use local variables, you just string the commands together and get the result. I could make a complete RPL program buy pasting all those individual commands I just wrote to represent the individual calculations into one RPL command. That does work, but it doesn't take advantage of the fact that if you know ahead of time about all the stuff on the stack you could probably rewrite the individual calculations in the problem to take advantage of stuff on the stack and the program would actually be more efficient. But with more than some number of items on the stack it starts to get really hairy. I did something today and the stack depth got to 5 or 6 and I felt like more than that becomes unmanagable quickly.

So. How bad are local variables in terms of storage and time? How many items is it reasonable to keep on the stack before it's a bad idea? And can anybody help with general guidance on how to program a big solution elegantly in RPL that contains many individual calculations and temporary results where those temporary results aren't useful enough to be saved as commands to be reused in other solutions?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RPL programming questions - HP67 - 02-17-2014 01:54 PM
RE: RPL programming questions - peacecalc - 02-17-2014, 03:10 PM
RE: RPL programming questions - Joe Horn - 02-18-2014, 01:06 PM
RE: RPL programming questions - HP67 - 02-18-2014, 01:39 PM
RE: RPL programming questions - peacecalc - 02-18-2014, 07:15 PM
RE: RPL programming questions - DavidM - 02-18-2014, 11:31 PM
RE: RPL programming questions - HP67 - 02-19-2014, 09:52 AM
RE: RPL programming questions - HP67 - 02-19-2014, 02:15 PM
RE: RPL programming questions - HP67 - 02-20-2014, 03:27 PM
RE: RPL programming questions - DavidM - 02-19-2014, 05:23 PM
RE: RPL programming questions - HP67 - 02-20-2014, 03:40 PM
RE: RPL programming questions - DavidM - 02-20-2014, 04:10 PM
RE: RPL programming questions - peacecalc - 02-19-2014, 04:15 PM
RE: RPL programming questions - HP67 - 02-20-2014, 04:36 PM
RE: RPL programming questions - RMollov - 02-24-2014, 12:47 PM



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