2022-10-28 00:55:25 +02:00
|
|
|
|
# Introduction to RPL
|
2022-10-20 23:34:44 +02:00
|
|
|
|
|
2022-10-27 23:32:00 +02:00
|
|
|
|
The original RPL (*Reverse Polish Lisp*) programming language was designed and
|
2022-10-20 23:34:44 +02:00
|
|
|
|
implemented by Hewlett Packard for their calculators from the mid-1980s until
|
|
|
|
|
2015 (the year the HP50g was discontinued). It is based on older calculators
|
2022-10-27 23:32:00 +02:00
|
|
|
|
that used RPN (*Reverse Polish Notation*). Whereas RPN had a limited stack size of
|
2022-10-20 23:34:44 +02:00
|
|
|
|
4, RPL has a stack size only limited by memory and also incorporates
|
2022-10-27 23:32:00 +02:00
|
|
|
|
programmatic concepts from the Lisp programming language.
|
2022-10-20 23:34:44 +02:00
|
|
|
|
|
2022-10-27 23:32:00 +02:00
|
|
|
|
The first implementation of RPL accessible by the user was on the HP28C, circa
|
|
|
|
|
1987, which had an HP Saturn processor. More recent implementations (e.g., HP49,
|
|
|
|
|
HP50g) run through a Saturn emulation layer on an ARM based processor. These
|
|
|
|
|
ARM-based HP calculators would be good targets for a long-term port of DB48X.
|
|
|
|
|
|
|
|
|
|
DB48X is a fresh implementation of RPL on ARM, initially targetting the
|
|
|
|
|
SwissMicros DM42 calculator. This has [implications on the design](#design-overview)
|
|
|
|
|
of this particular implementation of RPL.
|
|
|
|
|
|
|
|
|
|
## The RPL stack
|
|
|
|
|
|
|
|
|
|
The RPL stack can grow arbitrarily in size.
|
|
|
|
|
|
|
|
|
|
By convention, and following RPN usage, this document gives the names `X`, `Y`,
|
|
|
|
|
`Z` and `T` to the first four levels of the stack. This is used to describe the
|
|
|
|
|
operations on the stack with synthetic stack diagrams showing the state of the
|
|
|
|
|
stack before and after the operation.
|
|
|
|
|
|
|
|
|
|
For example, the addition of two objects in levels 1 and 2 with the result
|
|
|
|
|
deposited in stack level 1 can be described in synthetic form using the
|
|
|
|
|
following stack diagram:
|
|
|
|
|
|
|
|
|
|
`Y` `X` ▶ `Y+X`
|
|
|
|
|
|
|
|
|
|
The duplication
|
|
|
|
|
|
|
|
|
|
## Algebraic mode
|
|
|
|
|
|
|
|
|
|
Unlike earlier RPN calculators, RPL includes complete support for algebraic
|
|
|
|
|
objects written using the standard precedence rules in mathematics. In RPL,
|
|
|
|
|
algebraic expressions are placed between ticks. For example, `'2+3×5'` will
|
|
|
|
|
evaluate as `17`: the multiplication `3×5`, giving `15`, is performed before the
|
|
|
|
|
addition `2+15`, which gives `17`.
|
|
|
|
|
|
|
|
|
|
Algebraic expressions are not evaluated automatically. The _R/S_ key (bound to
|
|
|
|
|
the [Evaluate](#evaluate) function) will compute their value.
|