Proposal: EXCEPTION LOCALs
This proposal has been moved into this section. Its former address was: /standard/exception/THROW
This page is dedicated to discussing this specific proposal
AndrewRead EXCEPTION LOCALsProposal2017-10-28 07:04:49
Disclaimer - my opinion is biased by the work I have already done on my hardware Forth machine
Conceptually I see BASE, and STATE (and some variables connected to the standard input / output) not as GLOBALs but as "EXCEPTION LOCALs". I.e. variables located on the exception stack. (My analogy here is with the more familiar "SUBROUTINE LOCALs" we are familiar with from the subroutine stack.)
When the Exception stack is PUSH_ed (by CATCH), then the current values of BASE etc. are pushed onto the Exception stack too.
When the Exception stack in POP_ed (by 1 THROW), then the current values of BASE etc. are discarded and the values from the exception layer above become current.
This is easy to implement if BASE etc. are located wherever the exception stack is located. I do it in hardware, but that's a detail.