Python to RPN converter
|
11-04-2018, 10:25 PM
Post: #45
|
|||
|
|||
RE: Python to RPN converter
(11-04-2018 02:02 PM)Thomas Okken Wrote: Can't you access registers like REGS[index]? I suppose I could open up access to the registers in the way you suggest. Keep in mind however that by default, numbered registers are used to store Python variables, so registers are being pretty much being overwritten all the time and thus don't have much value. Specifically, all lowercase python variables are mapped to RPN registers in the order that the converter parser sees them. Thus a = 10 and b = 20 will be mapped to registers 00 and 01 respectively. The Python to RPN converter does offer ways of mapping Python variables to RPN named variables, by using uppercase Python variable names, or the special comment directive 'named' e.g. Code: y = 100 # rpn: named however the default behaviour is to use registers, to avoid polluting the HP42S/Free42 global namespace with dozens of variable names from your Python programs. In retrospect, perhaps the better implementation would have been to store all the Python variables in a dedicated HP42S matrix and grow the matrix as necessary to house new variables etc. This would have been more work to implement and would result in more verbose generated RPN. However now that the converter is built, it's an area that I may revisit one day. -Andy |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)