newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25]
|
08-09-2017, 08:35 PM
Post: #4
|
|||
|
|||
RE: newRPL: Alpha demo 0.9 released
(08-09-2017 03:57 PM)The Shadow Wrote: Most of the additions are obvious, but I'm puzzled by SPUSH, SPOP, and SDROP. Can't find them in any menus as yet, either.They are stack snapshot management commands (not on menus yet): SPUSH: Takes a new snapshot of the current stack. You'll be able to use left-cursor to go back to this state after your code ends. While the UNDO feature does this automatically, but you might want to create other intermediate snapshots, perhaps for debugging an intermediate step. SPOP: Revert the current stack to the last snapshot taken. SDROP: Delete the last snapshot taken (without touching the current stack). Why these commands? They help create routines that leave the stack on a predictable state on error, by trapping the error and restoring the stack before returning. I added them in preparation for higher level commands to be written in RPL. But I want them to leave the stack untouched on error, so I will need this. (08-09-2017 03:57 PM)The Shadow Wrote: I have an inkling of what BLAMEERR does, but I'm curious as to the syntax. Also, no help. Along the same lines, for proper error management on an RPL program sometimes you need to throw an error, blaming certain command for it. It works like this: "IDIDTHAT" "But wasn't my fault" BLAMEERR (08-09-2017 03:57 PM)The Shadow Wrote: Any chance of having RND do the 'nint' function instead of always rounding 0.5 up? Or perhaps a flag to cause it to work that way?I can look into that. For now the decimal library only supports one rounding mode but I can add more and control it with a flag. (08-09-2017 03:57 PM)The Shadow Wrote: HIDELOCALS and UNHIDELOCALS seem clear enough, I just can't figure out why one would want to? In newRPL, local variables are visible as globals to any subroutine: For example: << 5 'X' STO >> 'MYROUTINE' STO then if you run << 4 'X' LSTO MYROUTINE X >> the result would be 5, as X would be overwritten by MYROUTINE. This is on purpose and useful to encapsulate routines that modify global variables. If this is not what you want, then use the new commands: << 4 'X' LSTO HIDELOCALS MYROUTINE UNHIDELOCALS X >> Now because MYROUTINE can't see any locals created by any caller programs, it will create the global X variable with a 5, and the main program will result in a 4, since the last X refers to the local one, despite now having a global X=5. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: