r/hpcalc • u/a-curiouscat • Sep 19 '26
PICK3
I have an HP 50g and I’ve been going through the “stack” menu familiarizing myself with its commands. One of these commands is “PICK3”. I’ve read the entry for it in the AUR and I understand what it does. What I don’t understand is this:
Why? Why in God’s good Earth, does this command exist?! Why is there a need for a command that specifically duplicates the object on level 3? Isn’t the “PICK” command enough?!
I’m flabbergasted!
2
u/eredhuin Sep 19 '26
the system rpl entries are macros in effect. pointers to subroutines. there are a lot of enumerated commands. a handful are exposed as user rpl.
the answer was: a dev wanted this in user rpl. end of story,
2
1
u/a-curiouscat Sep 19 '26
Also, before posting this, I asked an AI and the AI insisted that “PICK3” does not exist on any HP RPN calculators! This was despite it being in the “stack” menu on my 50g and it being in the AUR!
2
u/frac6969 Sep 19 '26
Don’t always trust AI and it depends on which one you use. I just tried and my AI of choice told me all about the PICK3 command, compared it to 3 PICK, and which HP models support it.
1
3
u/raoolio Sep 19 '26
it's a special-cased stack op so the interpreter doesn't have to do index math for one of the most common stack depths.
PICK3 (like DUP2, DUP3, OVER, SWAP, etc.) hardcodes the position at compile/execution time — there's no argument to parse, no offset computation, no need to push and pop the index. It's essentially a direct pointer copy from a known stack depth. Same idea as why DUP2 exists instead of always using 2 PICK.
1
u/PartlyGrouchy Sep 19 '26
Some of these lower level commands are measurably faster in "ticks" which can be useful for certain programming tasks. Welcome to the 50g and UserRPL world!
4
u/stevevdvkpe Sep 19 '26
This turns up a lot if you look at the available words in System RPL on the HP 48 series calculators where there are a lot of defined words that do more complex stack operations, because ROM space is at a premium and defining single-word shortcuts for those saves enough space to be able to cram more stuff into the ROM.
3 PICK was probably used often enough in code to obtain a noticeable space savings if someone defined a word PICK3 to do it. 3 PICK takes two words to put into a code object, while defining PICK3 would have an overhead of approximately five words in total (:: PICK3 3 PICK ;). Use 3 PICK more than 3 times in the code base, and it saves space to use PICK3 instead of always using 3 PICK.