Content deleted Content added
Matthiaspaul (talk | contribs) CE |
Matthiaspaul (talk | contribs) CE, improved refs |
||
Line 2:
{{About||the programming language for the Commodore PET/CBM computers|Reverse Polish Language|the compiled database programming language|Real-time Programming Language}}
{{Use dmy dates|date=April 2019|cs1-dates=y}}
{{Use list-defined references|date=October 2023}}
{{Infobox programming language
| name = RPL
| logo =
| paradigm = [[stack-oriented programming language|Stack]], [[structured programming|structured]], [[concatenative programming language|concatenative]],<ref name="Joy_2020"/> partially [[object-oriented]]<ref name="Urroz_2000"/><ref name="RPL_2023"/><ref name="RPL_2003"/>
| year = 1984 (1986)
| designer = [[Hewlett-Packard]]
| developer =
| latest_release_version = <!-- X.Y.Z/{{release date|df=yes|YYYY|MM|DD}} -->
| latest_release_date = 2012-04-26<!-- HP 50g 2.16 --><ref name="HP_4"/><ref name="HP_7"/><ref name="HP_5"/><ref name="HP_6"/>
| discontinued = 2015<!-- HP 50g -->
| typing =
Line 17 ⟶ 18:
| influenced_by = [[Reverse Polish Notation|RPN]], [[Forth (programming language)|Forth]], [[Lisp (programming language)|Lisp]]<ref name="HPJ38"/>
| influenced =
| operating_system = [[Hewlett-Packard|HP]] [[
| license =
| website =
Line 26 ⟶ 27:
RPL is a [[structured programming]] language based on RPN, but equally capable of processing [[infix notation|algebraic]] expressions and formulae, implemented as a [[threaded code|threaded interpreter]].<ref name="RPL3"/> RPL has many similarities to [[Forth (programming language)|Forth]], both languages being [[stack-oriented programming language|stack]]-based, as well as the list-based [[LISP]]. Contrary to previous HP RPN calculators, which had a fixed [[4-level RPN|four-level stack]], the [[dynamic RPN stack|dynamic stack]] used by RPL is only limited by available [[random-access memory|RAM]], with the calculator displaying an error message when running out of memory rather than silently dropping arguments off the stack as in fixed-sized RPN stacks.<ref name="Wessman_2016"/>
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]].<ref name="RPLMAN"/> The last pocket calculator supporting RPL, the HP 50g, was discontinued in 2015.<ref name="Kuperus_2015_1"/><ref name="Kuperus_2015_2"/><ref name="Wessman_2015"/> However,
==Variants==
The internal low- to medium-level variant of RPL, called '''[[HP 49 series#Programming|System RPL]]''' (or '''SysRPL''') is used on some earlier HP calculators as well as the aforementioned ones, as part of their [[operating system]] implementation language.
==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.
IF condition THEN if-true [ELSE if-false] END
Line 45 ⟶ 46:
« 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.
« 1 == IF THEN "Equal to one" END »
Line 52 ⟶ 53:
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 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":
Line 58 ⟶ 59:
« 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".
« 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.
«
Line 72 ⟶ 73:
====CASE/THEN/END====
To support more complex conditional logic, RPL provides the CASE/THEN/END structure for handling multiple exclusive tests.
CASE
Line 81 ⟶ 82:
END
The following code illustrates the use of a CASE/THEN/END block.
«
Line 116 ⟶ 117:
====FOR/NEXT====
RPL provides a FOR/NEXT statement for looping from one index to another.
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.
«
Line 131 ⟶ 132:
====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.
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.
« 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.
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.
DO loop_statement UNTIL condition END
Line 159 ⟶ 160:
== Notes ==
:1.{{note|rpl_acronym_note_1}} "RPL" is derived from '''Reverse Polish Lisp''' according to its original developers,<ref name="Wickes_1988"/><ref name="Wickes_1991"/><ref name="Schoorl_2000"/><ref name="FAQ48"/><ref name="Nelson_2012"/><ref name="Jedrzejowicz_1996"/> while for a short time in 1987 HP marketing attempted to coin the [[backronym]] '''ROM-based Procedural Language''' for it.<ref name="HPJ38"/><ref name="Jedrzejowicz_1996"/><ref name="HP_2007"/> In addition, the RPL initials are sometimes incorrectly interpreted as Reverse Polish Logic or [[Reverse Polish Language]].<ref>{{cite web |url=https://www.hpcalc.org/hp48/docs/hpedia/ |title=HPedia: The HP Calculator Encyclopedia |author-last1=Rechlin |author-first1=Eric |author-last2=Marangon |author-first2=Carlos |website=www.hpcalc.org |access-date=2020-04-20}}</ref>
==References==
{{Reflist|refs=
<ref name="Joy_2020">{{cite web |url=https://www.hpmuseum.org/forum/showthread.php?mode=linear&tid=15509&pid=135732 |title=The Joy of Programming? |publisher=Museum of HP Calculators |date=2020 |archive-url=https://web.archive.org/web/20211203131528/https://www.hpmuseum.org/forum/showthread.php?mode=linear&tid=15509&pid=135732 |archive-date=2021-12-03}}</ref>
<ref name="Urroz_2000">{{cite book |author-first=Gilberto E. |author-last=Urroz |title=Programming the HP 49 G Calculator in User RPL Language |date=2000 |url=https://h30434.www3.hp.com/psg/attachments/psg/palm-webossoftware/252122/1/hp49g04.pdf |archive-url=https://web.archive.org/web/20221031143355/https://h30434.www3.hp.com/psg/attachments/psg/palm-webossoftware/252122/1/hp49g04.pdf |archive-date=2022-10-31}}</ref>
<ref name="RPL_2023">{{cite web |url=https://www.hpmuseum.org/rpl.htm |title=RPL |publisher=Museum of HP Calculators |archive-url=https://web.archive.org/web/20230820203818/https://www.hpmuseum.org/rpl.htm |archive-date=2023-08-20}}</ref>
<ref name="RPL_2003">{{cite web |url=https://archived.hpcalc.org/museumforum/thread-35921.html |title=RPN/RPL — What? |date=2003 |publisher=Museum of HP Calculators |archive-url=https://web.archive.org/web/20230820204017/https://archived.hpcalc.org/museumforum/thread-35921.html |archive-date=2023-08-20}}</ref>
<ref name="HP_4">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{{dead link|date=April 2018 |bot=InternetArchiveBot|fix-attempted=yes}}</ref>
<ref name="HP_7">http://www.calculatrices-hp.com/index.php?page=emulateurs<!-- https://web.archive.org/web/20170917223308/http://www.calculatrices-hp.com/index.php?page=emulateurs --></ref>
<ref name="HP_5">{{cite web |url=http://www.hpmuseum.org/forum/thread-4405-post-39600.html |title=Emulator of HP 50g with #2.16 ROM}}</ref>
<ref name="HP_6">http://www.calculatrices-hp.com/uploads/emulateurs/HP50gVirtualCalculatorSetup_3_1_30.zip<!-- https://web.archive.org/web/20170917095533/http://www.calculatrices-hp.com/uploads/emulateurs/HP50gVirtualCalculatorSetup_3_1_30.zip --></ref>
<ref name="HPJ38">{{cite journal |title=Computation for Handheld Calculators |author-last=Patton |author-first=Charles M. |journal=[[Hewlett-Packard Journal]] |publisher=[[Hewlett-Packard Company]] |___location=Palo Alto, California, USA |date=August 1987 |volume=38 |issue=8 |pages=21–25 |url=http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1987-08.pdf |access-date=2015-09-12}}</ref>
<ref name="Wickes_1988">{{cite conference |title=RPL: A Mathematical<!-- also seen as: "Mathematics". Check actual publication's cover. --> Control Language |author-last=Wickes |author-first=William C. |editor-first=Lawrence P. |editor-last=Forsely |date=1988-10-01 |orig-date=14–18 June 1988 |conference=Proceedings of the 1988 Rochester Forth Conference: Programming Environments |volume=8 |publisher=Institute for Applied Forth Research, Inc., [[University of Rochester]] |___location=Rochester, New York, USA |isbn=978-0-91459308-9 |oclc=839704944 <!-- |doi=10.5555/534949--> |pages=27–32 |quote=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 (programming language)|Forth]] with the functional approach of [[Lisp (programming language)|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: [https://web.archive.org/web/20230328115142/https://www.hpcalc.org/details/1743][https://web.archive.org/web/20220419184811/https://www.hpcalc.org/hp48/docs/programming/rplman.zip])</ref>
|