ForthHub / standard-evolution

Evolving of the Forth Standard, sketches, issues and discussions
0 stars 0 forks source link

`quit` empties the exception stack #6

Open ruv opened 1 year ago

ruv commented 1 year ago

According to the original intention, the word quit in no way returns control to the caller.

Mitch Bradley, who was Vice Chair of the ANS FORTH committee, wrote in 1992 in comp.lang.forth:

the description of THROW says that, in the absence of explicitly-installed CATCH handlers, the behavior is like ABORT which eventually does the function of QUIT. An implementation of QUIT could do a "preemptive CATCH" and still be within the standard. This isn't surprising; a program that calls QUIT cannot expect to ever regain control anyway.

And quit is usually implemented in such a way that it never returns control.

But according to the specification (in Forth-1994 and Forth-2012), it shall return control if there is an exception frame on the exception stack and throw is performed by the user interactively. An example of call quit with an exception frame:

:noname ['] quit catch cr ." return from quit, ior: " . cr ; execute

Such behavior (i.e., a way to return control) was not intended, and usually is not implemented. So, it's an omission in the specification for quit. This specification should be corrected to say that quit empties the exception stack.

See also