[comp.lang.forth] Multiprogramming impact of CATCH and THROW

wmb@MITCH.ENG.SUN.COM (01/03/91)

> CATCH 14.1.0875 and THROW 14.1.2275 need the M attribute.
> Meta-operation on the return stack has multiprogramming impact
> in the form of a frame pointer that must be preserved through
> context Switches.

It is true that CATCH and THROW imply an implementation consideration
with respect to multiprogramming.  However, that does not mean that
the definition of the words themselves needs the M attribute, because
there is no user-visible shared resource that is invalidated by a
context switch.

The "exception frame pointer" is an implementation variable that is
invisible to the application program, nor is its existence necessarily
implied by CATCH and THROW (for instance, you could implement CATCH and
THROW with a tagged return stack; THROW would find the exception frame
by doing R> until it found the tag for the exception frame).

Certainly, if you choose to use the frame pointer implementation technique,
the frame pointer must be a USER variable, but this does not create a
"Multiprogramming Impact" for CATCH and THROW.  The correct way to document
this is in the "Implementor's Notes" section, by noting that the
exception frame pointer, if it exists, should be in the USER area.

By the way, this lack of multiprogramming impact is yet another way in
which CATCH and THROW is less of a "can of worms" than a "setjmp/longjmp"
approach to error handling.

Mitch Bradley, wmb@Eng.Sun.COM