Post Reply 
RPL second impressions (HP 28)
06-30-2018, 02:16 PM
Post: #30
RE: RPL second impressions (HP 28)
(06-30-2018 02:14 AM)Thomas Klemm Wrote:  Use only the simplest stack-manipulating commands as DUP, SWAP, OVER or ROT.


I could imagine that creating a context for local variables is somewhat expensive. So don't do that within a tight loop. But accessing local variables should be fast. Similar to something like DUP or +.

I would amend that slightly by saying that one should avoid stack commands that take a numerical argument (such as PICK and ROLL) whenever possible. They take several times as long to execute as simple stack commands. The newer commands such as PICK3, DUPDUP and NIP are just as fast as the basic ones you listed, and they save time and memory.

Local variables are faster than globals in programs but not as fast as stack operations.

When I am writing a program or translating one from another language, I tend to use lots of local variables and avoid complex stack gymnastics. This speeds development time and (slightly) increases readability. If the program is one I plan to keep and use often, I will further optimize it by eliminating variables as much as possible and using the stack more.

John
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) - John Keith - 06-30-2018 02:16 PM
RE: RPL second impressions (HP 28) - ttw - 07-04-2018, 10:52 PM



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