DB48X: HP48-like RPL implementation for DM42
|
07-17-2023, 06:27 AM
Post: #22
|
|||
|
|||
RE: DB48X: HP48-like RPL implementation for DM42
(07-16-2023 09:36 AM)Gilles Wrote: Very promising and complementary to newRPL! That could make me buy a DM42 ;D I've not looked in details at the implementation of local variables in newRPL, but I'm afraid I won't implement LSTO as described in their manual. You can, however, `STO` in an existing local. The reason is that local variables in db48x are designed to be as efficient as the stack. Internally, they are like numbered registers. Each local access is a two-bytes opcode. For example, << -> A B << B A >> >> will create two local names A and B. The two references that you see in the inner block are then turned into local(0) and local(1) respectively (so two bytes, one for 'ID_local", one for the index, which is one byte unless you declare more than 127 local variables in a single block, something that should work but that I frankly have not tested yet...). This means that evaluating local(0) is just an array index, there is no name lookup (name lookup was done at parsing time). Note that the index of a 'for' loop is also a local. You can "simulate" the effect of LSTO with something like << 0 -> X << do-something 'X' STO do-something-else >> >>. In other words, you *can* store to a local variable, and it's much faster than store to a global variable, again because it's just an array access. But this optimization, which I believe is really important, also means that the parser and renderer need to be aware of local names, so you cannot declare them anywhere. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: