RPL (programming language)

Reverse Polish Lisp ( RPL ) is a stack-based programming language similar to FORTH, which is used in the Hewlett -Packard calculators like the HP -28, HP- 48, and in more recent series such as the HP- 49 and HP-50. The language was developed in the HP office in Corvallis in the U.S. state of Oregon in 1984. The goal was to find a replacement for the hitherto usually programmed in assembler operating software in calculators.

Background

One anecdote of one of the participating RPL developer Dr. William Wickes According to the designation is arbitrary. Program code in RPL can be entered as the inverse Polish Notation (RPN / RPN ). From LISP language has essentially the property to use lists of any content as data type, basic ( Lisp ) perform operations on and with many RPL commands to operate on them, such as:

Or in algebraic mode:

The instruction set is different for the different calculators rows. More complex programs are, therefore, not upward, but mostly backwards compatible. There are two dialects of the language, the more comfortable User RPL and the hardware more detailed, but more powerful Sys RPL.

The use of the Reversed Polish Notation leads to an unfamiliar, after getting used to but efficient command sequence, wherein the data to be processed are recorded always in front of the edit commands ( first elements are placed on the stack, then an operator on it applied).

Example

The following sample program shows the numbers from 1 to 100 in the first screen prompt:

" 1100 FOR I     I 1 DISP     NEXT » The program is executed by the computer as follows:

  • First, the numbers 1 and 100 onto the stack
  • The FOR command removes these two numbers from the stack again, it saves as a start and end value of the loop and recognizes the following identifiers as I run variable of the FOR statement (I here is a global variable )
  • From the next statement inside the FOR loop begins. First, the current value of the variable I is placed on the stack.
  • DISP removed both the value of I and the 1 off the stack and shows I in the first line of the display.
  • NEXT marks the end of the loop structure

In most cases, the transfer of arguments is done so that they are first put on the stack, and even take control structures these values ​​as functions as arguments. Even comparisons work like this:

« → a    " IF a 1>      THEN a LOG      ELSE a 1      END    » » Description of the sample:

  • At the beginning of the program, a value is popped from the stack and moved from → in the temporary variable a. The a variable exists only as long as the program is executed within the inner ""
  • The value of the local variable a and 1 are placed on the stack
  • The comparison > is as mathematical operation (eg ), which a and 1 is removed from the stack and instead the result of the comparison on the stack sets (0 = FALSE, 1 = TRUE)
  • The following statement THEN then takes the result of the comparison ( 0 or 1) from the stack and continues processing either THEN ELSE or ELSE up to END

For the execution in RPL, it is not relevant when the comparison value was provided as an argument for THEN. Alternatively, the line may look with the IF also like:

...    «A 1> IF ... References

  • Lisp
679910
de