词条 | RPL (programming language) |
释义 |
| name = RPL | logo = | paradigm = stack, structured, object-oriented | year = 1984 (1986) | designer = Hewlett-Packard | developer = | latest_release_version = | latest_release_date = 2012-04-26[1][2][3][4] | discontinued = 2015 | typing = | implementations = | dialects = System RPL, User RPL | influenced_by = RPN, Forth, Lisp | influenced = | operating_system = HP calculators | license = | website = | file_ext = }} RPL (derived from Reverse Polish Lisp according to its original developers,[6][7][8][9][10][11] whilst for a short while in 1987 HP marketing attempted to coin the backronym ROM-based Procedural Language for it[11][14]) is a handheld calculator operating system and application programming language used on Hewlett-Packard's scientific graphing RPN (Reverse Polish Notation) calculators of the HP 28, 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 language based on RPN, but equally capable of processing algebraic expressions and formulae, implemented as a threaded interpreter.[15] RPL has many similarities to Forth, 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. 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.[16] The last pocket calculator supporting RPL, the HP 50g, was discontinued in 2015.[17][18][19] 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. VariantsThe 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 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 in 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 blocksRPL 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 statementsIF/THEN/ELSE/ENDRPL supports basic conditional testing through the IF/THEN/ELSE structure. The basic syntax of this block is: 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": 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: IFT/IFTEPostfix 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": 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": 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/ENDTo 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 statementsFOR/NEXTRPL 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: 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/NEXTThe 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: FOR/STEP and START/STEPBoth 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: WHILE/REPEAT/ENDThe 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: DO/UNTIL/ENDThe 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: See also
References1. ^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}} [5][6][7][8][9][10][11][12][13][14][15][16]2. ^http://www.calculatrices-hp.com/index.php?page=emulateurs 3. ^http://www.hpmuseum.org/forum/thread-4405-post-39600.html 4. ^http://www.calculatrices-hp.com/uploads/emulateurs/HP50gVirtualCalculatorSetup_3_1_30.zip 5. ^1 {{cite book |title=RPL: A Mathematical Control Language |author-first=William C. |author-last=Wickes |date=1988 |work=Proceedings Rochester Forth Conference on Programming Environments |publisher=Institute for Applied Forth Research, Inc. |location=Rochester, New York, USA |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 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.}} 6. ^1 {{cite web |title=HP48 Frequently Asked Questions List |author-first=André |author-last=Schoorl |date=2000-04-04 |pages=69 |publisher=HP Calculator Archive |orig-year=1997 |url=http://www.hpcalc.org/hp48/docs/faq/48faq-pdf.zip |access-date=2015-09-12}} 7. ^1 {{cite web |title=I've heard the names RPL, Saturn, STAR, GL etc... What are they? - RPL |work=FAQ: 2 of 4 - Hardware, Programs, and Programming |id=8.1. |publisher=comp.sys.hp48 |date=2000-04-14 |version=4.62 |url=http://www.faqs.org/faqs/hp/hp48-faq/part2/ |access-date=2015-09-12}} 8. ^1 {{cite journal |title=HP RPN Evolves |author-first=Richard J. |author-last=Nelson |publisher=Hewlett-Packard |journal=HP Solve |issue=27 |date=2012-04-04 |pages=30–32 |url=http://h20331.www2.hp.com/hpsub/downloads/HP_Calculator_eNL_04_April_2012%20(2).pdf |access-date=2015-09-12}} 9. ^1 2 {{cite book |title=A Guide to HP Handheld Calculators and Computers |author-first=Włodek A. C. |author-last=Mier-Jedrzejowicz |date=July 1991 |publisher=HHC 2011 |edition=5 |isbn=978-1888840308 |id=1888840307 |quote=RPL stands for Reverse Polish Lisp - it combined the RPN calculator language of earlier models with features of the Lisp and Forth programming languages. For a time HP explained the letters RPL as an acronym for "ROM-based Procedural Language".}} 10. ^1 {{cite web |title=HP Celebrates 35 Years of Handheld Calculator Innovation |publisher=Hewlett-Packard Development Company, L.P. |date=2007 |url=http://h20331.www2.hp.com/Hpsub/cache/457008-0-0-225-121.html |archive-url=https://web.archive.org/web/20070317053857/http://h20331.www2.hp.com/Hpsub/cache/457008-0-0-225-121.html |archive-date=2007-03-17 |access-date=2015-09-13 |quote=1987: HP-28C: First full RPL calculator: In the late 1980s, HP developed a new programming language for its new series of extremely powerful calculators. By combining elements of RPN, Lisp and Forth, HP came up with a language called RPL (or ROM-based Procedural Language).}} 11. ^1 {{cite web |title=What is RPL? |author-first=Joseph K. |author-last=Horn |url=http://www.hpcalc.org/hp48/docs/programming/rpl3.txt |access-date=2017-09-17 |dead-url=no |archive-url=https://web.archive.org/web/20170917221524/http://www.hpcalc.org/hp48/docs/programming/rpl3.txt |archive-date=2017-09-17}} 12. ^1 {{cite web |title=RPLMan from Goodies Disk 4 |author=Hewlett-Packard |format=RPLMAN.ZIP |url=http://www.hpcalc.org/details.php?id=1743 |access-date=2015-09-12}} 13. ^1 {{cite web |title=RPL stands for Reverse Polish Lisp |author-first=William C. |author-last=Wickes |publisher=www.hpcalc.org |date=1991-03-11 |url=http://www.hpcalc.org/hp48/docs/programming/rpl.txt |access-date=2015-09-12 |quote=RPL stands for Reverse Polish Lisp. In the early days of RPL development, we got tired of calling the unnamed system "the new system", and one of the development team came up with "RPL", both as a play on "RPN" which has been the loved/hated hallmark of HP calcs forever, and as an accurate indication of the derivation of the language from Forth and Lisp. RPL was never particularly intended to be a public term; at the time of the HP Journal article (August 1987) on the HP 28C there 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.}} 14. ^1 {{cite web |title=HP 50g: End of an era |author-first=Klaas |author-last=Kuperus |publisher=Moravia |date=2015-03-04 |url=http://forum.hp-prime.de/discussion/787/hp-50g-end-of-an-era |dead-url=yes |archive-url=https://web.archive.org/web/20150402112232/http://forum.hp-prime.de/discussion/787/hp-50g-end-of-an-era |archive-date=2015-04-02}} 15. ^1 {{cite web |title=HP 50g not so good news? |author-first=Klaas |author-last=Kuperus |publisher=Moravia |date=2015-03-06 |url=http://www.hpmuseum.org/forum/thread-3265-post-29694.html#pid29694 |access-date=2016-01-01}} 16. ^1 {{cite web |title=Windows 10 won't allow HP 50g USB drivers to be installed |author-first=Timothy James |author-last=Wessman |publisher=HP Museum |date=2015-12-26 |url=http://www.hpmuseum.org/forum/thread-5386-post-48114.html#pid48114 |access-date=2016-01-01}} }} Further reading
{{anchor|RPL/2|newRPL|rpn}}External links
4 : Stack-oriented programming languages|Graphing calculators|HP calculators|Lisp programming language family |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。