RPL (programming language)
RPL[5] is a
RPL is a
RPL originated from HP's
Variants
The internal low- to medium-level variant of RPL, called
Control blocks
RPL control blocks are not strictly
Conditional statements
IF/THEN/ELSE/END
RPL supports basic conditional testing through the IF/THEN/ELSE structure. The basic syntax of this block is:
IF condition THEN if-true [ELSE if-false] END
The following example tests to see if the number at the bottom of the stack is "1" and, if so, replaces it with "Equal to one":
« IF 1 == THEN "Equal to one" END »
The IF construct evaluates the condition then tests the bottom of the stack for the result. As a result, RPL can optionally support FORTH-style IF blocks, allowing the condition to be determined before the block. By leaving the condition empty, the IF statement will not make any changes to the stack during the condition execution and will use the existing result at the bottom of the stack for the test:
« 1 == IF THEN "Equal to one" END »
IFT/IFTE
Postfix conditional testing may be accomplished by using the IFT ("if-then") and IFTE ("if-then-else") functions.
IFT and IFTE pop two or three commands off the stack, respectively. The topmost value is evaluated as a boolean and, if true, the second topmost value is pushed back on the stack. IFTE allows a third "else" value that will be pushed back on the stack if the boolean is false.
The following example uses the IFT function to pop an object from the bottom of the stack and, if it is equal to 1, replaces it with "One":
« 1 == "One" IFT »
The following example uses the IFTE function to pop an object from the bottom of the stack and, if it is equal to 1, replaces it with "One". If it does not equal 1, it replaces it with the string "Not one":
« 1 == "One" "Not one" IFTE »
IFT and IFTE will evaluate a program block given as one of its arguments, allowing a more compact form of conditional logic than an IF/THEN/ELSE/END structure. The following example pops an object from the bottom of the stack, and replaces it with "One", "Less", or "More", depending on whether it is equal to, less than, or greater than 1.
« DUP 1 == « DROP "One" » « 1 < "Less" "More" IFTE » IFTE »
CASE/THEN/END
To support more complex conditional logic, RPL provides the CASE/THEN/END structure for handling multiple exclusive tests. Only one of the branches within the CASE statement will be executed. The basic syntax of this block is:
CASE condition_1 THEN if-condition_1 END ... condition_n THEN if-condition_n END if-none END
The following code illustrates the use of a CASE/THEN/END block. Given a letter at the bottom of the stack, it replaces it with its string equivalent or "Unknown letter":
« CASE DUP "A" == THEN "Alpha" END DUP "B" == THEN "Beta" END DUP "G" == THEN "Gamma" END "Unknown letter" END SWAP DROP @ Get rid of the original letter »
This code is identical to the following nested IF/THEN/ELSE/END block equivalent:
« IF DUP "A" == THEN "Alpha" ELSE IF DUP "B" == THEN "Beta" ELSE IF DUP "G" == THEN "Gamma" ELSE "Unknown letter" END END END SWAP DROP @ Get rid of the original letter »
Looping statements
FOR/NEXT
RPL provides a FOR/NEXT statement for looping from one index to another. The index for the loop is stored in a temporary local variable that can be accessed in the loop. The syntax of the FOR/NEXT block is:
index_from index_to FOR variable_name loop_statement NEXT
The following example uses the FOR loop to sum the numbers from 1 to 10. The index variable of the FOR loop is "I":
« 0 @ Start with zero on the stack 1 10 @ Loop from 1 to 10 FOR I @ "I" is the local variable I + @ Add "I" to the running total NEXT @ Repeat... »
START/NEXT
The START/NEXT block is used for a simple block that runs from a start index to an end index. Unlike the FOR/NEXT loop, the looping variable is not available. The syntax of the START/NEXT block is:
index_from index_to START loop_statement NEXT
FOR/STEP and START/STEP
Both FOR/NEXT and START/NEXT support a user-defined step increment. By replacing the terminating NEXT keyword with an increment and the STEP keyword, the loop variable will be incremented or decremented by a different value than the default of +1. For instance, the following loop steps back from 10 to 2 by decrementing the loop index by 2:
« 10 2 START -2 STEP »
WHILE/REPEAT/END
The WHILE/REPEAT/END block in RPL supports an indefinite loop with the condition test at the start of the loop. The syntax of the WHILE/REPEAT/END block is:
WHILE condition REPEAT loop_statement END
DO/UNTIL/END
The DO/UNTIL/END block in RPL supports an indefinite loop with the condition test at the end of the loop. The syntax of the DO/UNTIL/END block is:
DO loop_statement UNTIL condition END
See also
- A Programming Language(APL)
- FOCAL keystroke programming
- High Performance Language(HPL)
- HP trigraphs
- Prime Programming Language(PPL)
- RPL character set
Notes
- 1.Reverse Polish Language.[26]
References
- ^ "The Joy of Programming?". Museum of HP Calculators. 2020. Archived from the original on 2021-12-03.
- ^ Hewlett-Packard Company: 21–25. Archived from the original(PDF) on 2011-12-06. Retrieved 2015-09-12.
- ^ http://h41268.www4.hp.com/live/index_e.aspx?qid=20709&jumpid=va_r11363_us/en/any/tsg/pl_ot_ob_ds_pd/calculatoremulators_cc/dt[permanent dead link]
- ^ http://www.calculatrices-hp.com/index.php?page=emulateurs
- ^ "Emulator of HP 50g with #2.16 ROM".
- ^ http://www.calculatrices-hp.com/uploads/emulateurs/HP50gVirtualCalculatorSetup_3_1_30.zip
- ^ a b c Hewlett-Packard. "RPLMan from Goodies Disk 4" (RPLMAN.ZIP). Retrieved 2015-09-12.
- ^ Horn, Joseph K. "What is RPL?". Archived from the original on 2017-09-17. Retrieved 2017-09-17.
- ^ Wessman, Timothy "Tim" James (2016-06-21) [2016-06-20]. "What to do with stack overflow OBJ->/LIST->?". MoHPC - The Museum of HP Calculators. Archived from the original on 2023-09-24. Retrieved 2023-09-24.
- ^ Wickes, William C. (January–February 1987). "The HP-28C: An Insider's Perspective". HPX Exchange. 1 (1). [1]
- ^ Kuperus, Klaas (2015-03-04). "HP 50g: End of an era". Moravia. Archived from the original on 2015-04-02.
- ^ Kuperus, Klaas (2015-03-06). "HP 50g not so good news?". Moravia. Retrieved 2016-01-01.
- ^ Wessman, Timothy "Tim" James (2015-12-26). "Windows 10 won't allow HP 50g USB drivers to be installed". MoHPC - The Museum of HP Calculators. Retrieved 2016-01-01.
- hp 39g+ as well as the HP Prime)
- ^ Lapilli, Claudio Daniel (2021-07-23) [2014]. "newRPL Documentation Project". newRPL. Archived from the original on 2023-11-03. Retrieved 2023-10-23.
- ^ de Dinechin, Christophe (2022). "DB48X on DM42 - RPL runtime for the DM42 calculator, in the spirit of HP48/49/50". DB48X. Archived from the original on 2023-11-03. Retrieved 2023-10-23.
- DM32.)
- ^ Lapilli, Claudio Daniel (2014-10-31). "N-Queens on 50g (RPL language)". MoHPC - The Museum of HP Calculators. Archived from the original on 2023-11-03. Retrieved 2023-10-23.
- OCLC 839704944.)
Several existing operating systems and languages were considered, but none could meet all of the design objectives. A new system was therefore developed, which merges the threaded interpretation of Forth with the functional approach of Lisp. The resulting operating system, known unofficially as RPL (for Reverse-Polish Lisp), made its first public appearance in June of 1986 in the HP-18C Business Consultant calculator.
(NB. This title is often cited as "RPL: A Mathematics Control Language". An excerpt is available at: [3][4] - HP Journal article (August 1987) on the HP 28Cthere was an attempt to create a less whimsical name--hence "ROM-based procedural language", which preserved the initials but had a more dignified sound. The development team never calls it anything but (the initials) RPL. You can choose either of the two full-word versions that you prefer. Or how about "Rich People's Language?" Bill Wickes, HP Corvallis.
- ^ Schoorl, André (2000-04-04) [1997]. "HP48 Frequently Asked Questions List". HP Calculator Archive. p. 69. Retrieved 2015-09-12.
- ^ "I've heard the names RPL, Saturn, STAR, GL etc... What are they? - RPL". FAQ: 2 of 4 - Hardware, Programs, and Programming. 4.62. comp.sys.hp48. 2000-04-14. 8.1. Retrieved 2015-09-12.
- ^ Nelson, Richard J. (2012-04-04). "HP RPN Evolves" (PDF). HP Solve (27). Hewlett-Packard: 30–32. Retrieved 2015-09-12.
- ^ ISBN 978-1-88884030-8. 1888840307.programming languages. For a time HP explained the letters RPL as an acronym for "ROM-based Procedural Language".
RPL stands for Reverse Polish Lisp - it combined the RPN calculator language of earlier models with features of the Lisp and Forth
- , HP came up with a language called RPL (or ROM-based Procedural Language).
- ^ Rechlin, Eric; Marangon, Carlos. "HPedia: The HP Calculator Encyclopedia". www.hpcalc.org. Retrieved 2020-04-20.
Further reading
- HP 48G Series – User's Guide (UG) (8th ed.). Hewlett-Packard. December 1994 [1993]. HP 00048-90126, (00048-90104). Archived from the original on 2016-08-06. Retrieved 2015-09-06. [6]
- HP 48G Series – Advanced User's Reference Manual (AUR) (4th ed.). Hewlett-Packard. December 1994 [1993]. HP 00048-90136, 0-88698-01574-2. Archived from the original on 2016-08-06. Retrieved 2015-09-06. [7]
- HP 50g graphing calculator user's guide (UG) (1 ed.). Hewlett-Packard. April 2006. HP F2229AA-90006. Retrieved 2015-09-06.
- HP 50g / 49g+ / 48gII graphing calculator advanced user's reference manual (AUR) (2 ed.). Hewlett-Packard. 2009-07-14 [2005]. HP F2228-90010. Retrieved 2015-09-06.
- Kalinowski, Eduardo de Mattos; Dominik, Carsten (2002-04-24) [1998-07-12]. Programming in System RPL (PDF) (2 ed.). Archived (PDF) from the original on 2016-01-14. Retrieved 2016-08-16. (Older version: [8])
- Donnelly, James (2009-03-01). Rechlin, Eric (ed.). An Introduction to HP 48 System RPL and Assembly Language Programming. Retrieved 2015-09-07.
External links
- Rechlin, Eric (2015) [1997]. "HP 49/50 Programming Documentation Files". HP Calculator Archive. Retrieved 2015-09-12.
- Rechlin, Eric (2015) [1997]. "HP 48 Programming Documentation Files". HP Calculator Archive. Retrieved 2015-09-12.
- Hicks, David G. (2013) [1995]. "RPL". The Museum of HP Calculators (MoHPC). Archived from the original on 2023-09-30. Retrieved 2015-09-12.
- Bertrand, Joël (2015) [2009]. "RPL/2 - a new Reverse Polish Lisp". Retrieved 2015-09-12. (a GPL licensed RPL clone)
- Rubet, Louis (2017-07-01). "rpn - opensource implementation of RPL". GitHub. Retrieved 2015-09-12. (Open source implementation of RPL with arbitrary precision)
- Suárez, Alvaro Gerardo (2018-05-01). "MyRPL - Union between HP41 and HP48 languages". Archived from the original on 2023-10-03. Retrieved 2018-05-04. (Mixed RPL (HP48) and FOCAL (HP41) language)