HP50g: local LBL and GOTO in user or sysRPL
|
09-09-2016, 10:35 AM
Post: #11
|
|||
|
|||
RE: HP50g: local LBL and GOTO in user or sysRPL
I guess I should showcase my version in a program as well...
The major differences to the other solutions are: - I'm using the on-board compiler - the offset is not embedded inside the code object but placed behind it, so the code object can be re-used. Here I'm using one of my favorite tricks, storing a subroutine (the goto code) in a local variable: Code: :: I used a named LAM here to improve readability; unnamed LAMs would be faster and smaller, but unfortunately NULLLAM and 2GETEVAL are the only commands fetching and evaluating an unnamed LAM in one go, others need a separate EVAL. But I'll have to ask: what usecases for goto does SysRPL have? In C I sometimes use goto, but only for errors (either jumping to an error handling section at the end of a function, or jumping to the start from inside nested code blocks when an error prompts a retry). With RPL's error handling functions (ERRSET...ERRTRAP and ERRJMP) these usecases vanish. The former should be obvious, the latter can be handled by letting the error cascade up the return stack to the "code block" (i.e. secondary) that should be repeated, and constructing a BEGIN...UNTIL loop there. So what do you need this for? (Or are you just curious how it could be implemented?) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)