What makes exception frames different from other data in the return stack?
I am trying to understand how exception frames are laid out on the return stack at time THROW
.
The comments in "jonesforth.f.txt" state that "When called, THROW raises the return stack (a process called" unwinding ") until it finds an exception stack frame." I don't understand how it (EXCEPTION-MARKER)
differs from other data in the return stack (return addresses, custom values using >R
and signs for do-loops).
In general, how do the various Forths distinguish between exception frames and other data on the return stack?
source to share
Gforth does not seem to use this "unwinding" method.
Instead, it stores the location of the active frame of the exception in a global variable, keeping the previously active position of the frame in a new frame on the return stack. When an exception is thrown, Gforth reads the location of the last frame (largest internal catch) directly from the global variable.
In fact, in several other aspects that I have tested, I have not seen this implementation of the "unwind" method. All of these suggestions used the same idea of binding frames in a linked list with a head pointer stored in a global variable. This now looks typical for the following: http://lars.nocrew.org/dpans/dpansa9.htm
Perhaps Jones Forth relies on the assumption that only return addresses should be on the return stack at the time of throwing. The marker address is unique as it is a dictionary word. And typical loop indices do not reach this maximum, to be confused with the return address.
source to share