RPL is a
handheld calculator operating system and application
programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming ...
used on
Hewlett-Packard
The Hewlett-Packard Company, commonly shortened to Hewlett-Packard ( ) or HP, was an American multinational information technology company headquartered in Palo Alto, California. HP developed and provided a wide variety of hardware components ...
's scientific graphing
RPN (Reverse Polish Notation) calculators of the
HP 28
HP may refer to:
Businesses and organisations
* HP Inc., an American technology company
** Hewlett-Packard, the predecessor to HP Inc.
* HP Foods
** HP Sauce, formerly made by HP Foods
* Handley Page, an aircraft company
* Hindustan Petrole ...
,
48,
49 and
50 series, but it is also usable on non-RPN calculators, such as the
38,
39 and 40 series.
RPL is a
structured programming
Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection ( if/then/else) and repetition ( ...
language based on RPN, but equally capable of processing
algebraic expressions and formulae, implemented as a
threaded interpreter.
RPL has many similarities to
Forth
Forth or FORTH may refer to:
Arts and entertainment
* ''forth'' magazine, an Internet magazine
* ''Forth'' (album), by The Verve, 2008
* ''Forth'', a 2011 album by Proto-Kaw
* Radio Forth, a group of independent local radio stations in Scotla ...
, both languages being
stack-based, as well as the list-based
LISP. Contrary to previous HP RPN calculators, which had a fixed
four-level stack, the stack used by RPL is only limited by available calculator
RAM
Ram, ram, or RAM may refer to:
Animals
* A male sheep
* Ram cichlid, a freshwater tropical fish
People
* Ram (given name)
* Ram (surname)
* Ram (director) (Ramsubramaniam), an Indian Tamil film director
* RAM (musician) (born 1974), Dutch
* ...
.
RPL originated from HP's
Corvallis, Oregon development facility in 1984 as a replacement for the previous practice of implementing the
operating systems of calculators in
assembly language
In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence be ...
.
The last pocket calculator supporting RPL, the HP 50g, was discontinued in 2015.
However, multiple emulators that can emulate HP's RPL calculators exist that run on a range of operating systems, and devices, including iOS and Android smartphones.
Variants
The internal low- to medium-level variant of RPL, called
System RPL (or SysRPL) is used on some earlier HP calculators as well as the aforementioned ones, as part of their
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
implementation language. In the HP 48 series this variant of RPL is not accessible to the calculator user without the use of external tools, but in the HP 49/50 series there is a compiler built into ROM to use SysRPL. It is possible to cause a serious crash while coding in SysRPL, so caution must be used while using it. The high-level User RPL (or UserRPL) version of the language is available on said graphing calculators for developing textual as well as graphical application programs. All UserRPL programs are internally represented as SysRPL programs, but use only a safe subset of the available SysRPL commands. The error checking that is a part of UserRPL commands, however, makes UserRPL programs noticeably slower than equivalent SysRPL programs. The UserRPL command SYSEVAL tells the calculator to process designated parts of a UserRPL program as SysRPL code.
Control blocks
RPL control blocks are not strictly
postfix. Although there are some notable exceptions, the control block structures appear as they would in a standard infix language. The calculator manages this by allowing the implementation of these blocks to skip ahead in the program stream as necessary.
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
LSE if-falseEND
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 (named after the book ''A Programming Language'') is a programming language developed in the 1960s by Kenneth E. Iverson. Its central datatype is the multidimensional array. It uses a large range of special graphic symbols to represent mo ...
(APL)
*
FOCAL keystroke programming
The HP-41C series are programmable, expandable, continuous memory handheld RPN calculators made by Hewlett-Packard from 1979 to 1990. The original model, HP-41C, was the first of its kind to offer alphanumeric display capabilities. Later cam ...
*
High Performance Language (HPL)
*
HP trigraph
In computer programming, digraphs and trigraphs are sequences of two and three characters, respectively, that appear in source code and, according to a programming language's specification, should be treated as if they were single characters.
V ...
s
*
Prime Programming Language
The HP Prime Graphing Calculator is a graphing calculator introduced by Hewlett-Packard in 2013 and currently manufactured by HP Inc. It was designed with features resembling those of smartphones, such as a full-color touchscreen display and the ...
(PPL)
*
RPL character set The RPL character set is an 8-bit character set and encoding used by most RPL calculators manufactured by Hewlett-Packard as well as by the HP 82240B thermo printer. It is sometimes referred to simply as "ECMA-94" in documentation, although ...
Notes
:1. "RPL" is derived from Reverse Polish Lisp according to its original developers,
while for a short time in 1987 HP marketing attempted to coin the
backronym
A backronym is an acronym formed from an already existing word by expanding its letters into the words of a phrase. Backronyms may be invented with either serious or humorous intent, or they may be a type of false etymology or folk etymology. The ...
ROM-based Procedural Language for it.
In addition, the RPL initials are sometimes interpreted as Reverse Polish Logic, or Reverse Polish Language, but these names are not official.
References
Further reading
*
*
*
*
* (Older version
*
External links
*
*
*
* (a GPL licensed RPL clone)
*
(an open source RPL derivative for the
HP 50g
The HP 49/50 series are Hewlett-Packard (HP) manufactured graphing calculators. They are the successors of the popular HP 48 series.
There are five calculators in the 49/50 series of HP graphing calculators. These calculators have both ...
and
HP 49g+
The HP 49/50 series are Hewlett-Packard (HP) manufactured graphing calculators. They are the successors of the popular HP 48 series.
There are five calculators in the 49/50 series of HP graphing calculators. These calculators have both al ...
as well as for the
HP 40gs
HP 39/40 series are graphing calculators from Hewlett-Packard, the successors of HP 38G. The series consists of six calculators, which all have algebraic entry modes, and can perform numeric analysis together with varying degrees of symboli ...
,
HP 39gs
HP 39/40 series are graphing calculators from Hewlett-Packard, the successors of HP 38G. The series consists of six calculators, which all have algebraic entry modes, and can perform numeric analysis together with varying degrees of symbolic ...
and
hp 39g+)
* (Open source implementation of RPL with arbitrary precision)
* (Mixed RPL (HP48) and FOCAL (HP41) language)
{{DEFAULTSORT:Rpl (Programming Language)
Stack-oriented programming languages
*Rpl
RPL
Lisp programming language family