Post Reply 
RPL second impressions (HP 28)
06-29-2018, 07:14 PM
Post: #21
RE: RPL second impressions (HP 28)
(06-29-2018 04:59 PM)BartDB Wrote:  
(06-29-2018 02:49 PM)Thomas Okken Wrote:  This is a perfect example of what some people dislike about RPL: in order to write efficient programs, you have to avoid expressions and use stack manipulation instead..

Undecided ? that's what trditional RPN does too??

Besides, that's exactly what I like about RPL compared to e.g. Prime (and Casio/TI/Sharp)

And for RPL calculators, the stack is an "infinite" set of storage registers Smile

"Traditional" RPN has only four stack levels, which forces you to use numbered registers, or named variables on the later calculators that have them. That makes the flow of data a lot easier to follow.

When I see STO 00 and later on I see RCL 00, I know where that bit of data came from. I can't make such easy inferences when I'm looking at a bunch of DUP ROT SWAP etc.

(06-29-2018 05:13 PM)Thomas Klemm Wrote:  
(06-29-2018 01:08 PM)Gerson W. Barbosa Wrote:  That's one of my first RPL programs (HP-28S, back in 1987), so it can surely be optimized a bit.

Using local variables avoids stack juggling. Otherwise the changes were only minor.

Code:
«
  IF DUP 2 MOD
  THEN
    DUP √ → n r
    « 1
      DO
        2 +
      UNTIL
        r OVER <
        OVER n SWAP MOD NOT
        OR
      END
      n SWAP MOD NOT
    »
  END
  NOT
»

(06-29-2018 02:49 PM)Thomas Okken Wrote:  The resulting programs are hard to write and even harder to read.

Is that easy enough to understand?

Better, but no.

You still have to expend way too much mental energy to keep track of what is where in the stack. "r OVER < OVER n SWAP MOD NOT OR" is only "easy to read" for very specific values of "easy." Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:19 AM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:58 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 04:06 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 05:11 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 07:45 PM
RE: RPL second impressions (HP 28) - mdunn - 06-28-2018, 08:48 PM
RE: RPL second impressions (HP 28) - Thomas Okken - 06-29-2018 07:14 PM
RE: RPL second impressions (HP 28) - ttw - 07-04-2018, 10:52 PM



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