9 The optional Exception word set

9.1 Introduction

9.2 Additional terms and notation

None.

9.3 Additional usage requirements

9.3.1 THROW values

The THROW values {-255...-1} shall be used only as assigned by this standard. The values {-4095...-256} shall be used only as assigned by a system.

Programs shall not define values for use with THROW in the range {-4095...-1}.

9.3.2 Exception frame

An exception frame is the implementation-dependent set of information recording the current execution state necessary for the proper functioning of CATCH and THROW. It often includes the depths of the data stack and return stack.

9.3.3 Exception stack

A stack used for the nesting of exception frames by CATCH and THROW. It may be, but need not be, implemented using the return stack.

9.3.4 Possible actions on an ambiguous condition

A system choosing to execute THROW when detecting one of the ambiguous conditions listed in table 9.1 shall use the throw code listed there.

See: 3.4.4 Possible actions on an ambiguous condition.

Table 9.1: THROW code assignments

Code Reserved for Code Reserved for

-1ABORT
-2ABORT"
-3stack overflow
-4stack underflow
-5return stack overflow
-6return stack underflow
-7do-loops nested too deeply during execution
-8dictionary overflow
-9invalid memory address
-10division by zero
-11result out of range
-12argument type mismatch
-13undefined word
-14interpreting a compile-only word
-15invalid FORGET
-16attempt to use zero-length string as a name
-17pictured numeric output string overflow
-18parsed string overflow
-19definition name too long
-20write to a read-only location
-21unsupported operation
(e.g., AT-XY on a too-dumb terminal)
-22control structure mismatch
-23address alignment exception
-24invalid numeric argument
-25return stack imbalance
-26loop parameters unavailable
-27invalid recursion
-28user interrupt
-29compiler nesting
-30obsolescent feature
-31>BODY used on non-CREATEd definition
-32invalid name argument (e.g., TO name)
-33block read exception
-34block write exception
-35invalid block number
-36invalid file position
-37file I/O exception
-38non-existent file
-39unexpected end of file
-40invalid BASE for floating point conversion
-41loss of precision
-42floating-point divide by zero
-43floating-point result out of range
-44floating-point stack overflow
-45floating-point stack underflow
-46floating-point invalid argument
-47compilation word list deleted
-48invalid POSTPONE
-49search-order overflow
-50search-order underflow
-51compilation word list changed
-52control-flow stack overflow
-53exception stack overflow
-54floating-point underflow
-55floating-point unidentified fault
-56QUIT
-57exception in sending or receiving a character
-58[IF], [ELSE], or [THEN] exception
-59ALLOCATE
-60FREE
-61RESIZE
-62CLOSE-FILE
-63CREATE-FILE
-64DELETE-FILE
-65FILE-POSITION
-66FILE-SIZE
-67FILE-STATUS
-68FLUSH-FILE
-69OPEN-FILE
-70READ-FILE
-71READ-LINE
-72RENAME-FILE
-73REPOSITION-FILE
-74RESIZE-FILE
-75WRITE-FILE
-76WRITE-LINE
-77Malformed xchar
-78SUBSTITUTE
-79REPLACES

9.3.5 Exception handling

There are several methods of coupling CATCH and THROW to other procedural nestings. The usual nestings are the execution of definitions, use of the return stack, use of loops, instantiation of locals and nesting of input sources (i.e., with LOAD, EVALUATE, or INCLUDE-FILE).

When a THROW returns control to a CATCH, the system shall un-nest not only definitions, but also, if present, locals and input source specifications, to return the system to its proper state for continued execution past the CATCH.

9.4 Additional documentation requirements

9.4.1 System documentation

9.4.1.1 Implementation-defined options

9.4.1.2 Ambiguous conditions

9.4.1.3 Other system documentation

9.4.2 Program documentation

9.5 Compliance and labeling

9.5.1 Forth-2012 systems

The phrase "Providing the Exception word set" shall be appended to the label of any Standard System that provides all of the Exception word set.

The phrase "Providing name(s) from the Exception Extensions word set" shall be appended to the label of any Standard System that provides portions of the Exception Extensions word set.

The phrase "Providing the Exception Extensions word set" shall be appended to the label of any Standard System that provides all of the Exception and Exception Extensions word sets.

9.5.2 Forth-2012 programs

The phrase "Requiring the Exception word set" shall be appended to the label of Standard Programs that require the system to provide the Exception word set.

The phrase "Requiring name(s) from the Exception Extensions word set" shall be appended to the label of Standard Programs that require the system to provide portions of the Exception Extensions word set.

The phrase "Requiring the Exception Extensions word set" shall be appended to the label of Standard Programs that require the system to provide all of the Exception and Exception Extensions word sets.

9.6 Glossary

9.6.1 Exception words

9.6.2 Exception extension words