Post Reply 
Walkthrough of an RPL program for an RPN programmer
08-19-2018, 06:31 PM
Post: #14
RE: Walkthrough of an RPL program for an RPN programmer
(08-19-2018 05:15 PM)Vtile Wrote:  
Code:
« → a 'a+a' »

Will also work, but here the local variable is used in algebraic object. Confused

I don't actually think of this as an exception, but rather as overloaded functionality. As Albert has (correctly) noted, a single RPL operator (such as "+") can have multiple overloaded uses as defined by the types of arguments it is given. "→" also has overloaded functionality. In particular, it will execute either a program object («...») or an algebraic object ('...') with the provided locals. The action is essentially the same in both cases:

1) Assign as many stack items to local variable IDs as are indicated
2) Execute the final object
3) Release the most recently assigned local variables

The "→" operator is special (though not unique) in that it not only requires arguments on the stack, but it also requires objects following it in the program stream to be executed properly. The true "arguments" are already on the stack before it executes, and they end up being the values assigned to the local variables which follow the "→" operator in the program stream. The final object needed for the operator, though, is the single object which will be executed while those local variables are defined. So the «...» structure following the "→" operator is in reality still a single (encapsulated) object, not some exceptional version of the «» brackets.

Thinking of the "→" structure in this way makes it easier to understand what happens when local variable constructs are nested.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Walkthrough of an RPL program for an RPN programmer - DavidM - 08-19-2018 06:31 PM



User(s) browsing this thread: 1 Guest(s)