Post Reply 
newRPL: [UPDATED April 27-2017] Firmware for testing available for download
05-07-2017, 07:21 PM
Post: #659
RE: newRPL: [UPDATED April 27-2017] Firmware for testing available for download
(05-07-2017 06:21 AM)The Shadow Wrote:  In other news, I've been trying to determine the locked/unlocked state of a variable programmatically using the following:

<< DUP RCL SWAP IFERR STO THEN DROP2 1 ELSE 0 END >>

This works fine on unlocked variables, returning a 0 as expected; but when I try it on a locked variable, it throws a 'STO: Bad argument count' error. Even granted there's such an error, which there shouldn't be, why isn't the IFERR handling it?

A new feature in newRPL (yet to be documented properly... but at least we have a wiki now...) is that error handlers run under strict stack protection. The "Bad Argument count" is generated by DROP2, not by STO. But it's not easy to determine where an error is generated within an error handler itself (should be something like "error handler reentered" or something). But there's no easy way to generate that message and blame the right command.
This feature allows you to RESUME execution from the error handler. It's good when you setup error traps for a large program, and the error is predictable and you know you can safely ignore it (like "Infinite result" for example). For RESUME to be even possible, the stack and running environment must be preserved and the error handler should not be able to modify it.
Now back to your example, you just need to do your cleanup later.

<< DUP RCL SWAP IFERR STO THEN 1 ELSE 0 END
IF DUP THEN UNROT DROP2 END
>>



(05-07-2017 06:21 AM)The Shadow Wrote:  (How about a LOCK? or LVARS command? LOCK? would do what my above program does, testing a single variable; LVARS would return a list of all locked variables in the current directory. Wouldn't need both, one or the other would be sufficient.)

I don't see why not. I'll have to add ISLOCKEDVAR, ISHIDDENVAR or something like that.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL: [UPDATED April 27-2017] Firmware for testing available for download - Claudio L. - 05-07-2017 07:21 PM



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