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 |
|
|
-1 | ABORT |
-2 | ABORT" |
-3 | stack overflow |
-4 | stack underflow |
-5 | return stack overflow |
-6 | return stack underflow |
-7 | do-loops nested too deeply during execution |
-8 | dictionary overflow |
-9 | invalid memory address |
-10 | division by zero |
-11 | result out of range |
-12 | argument type mismatch |
-13 | undefined word |
-14 | interpreting a compile-only word |
-15 | invalid FORGET |
-16 | attempt to use zero-length string as a name |
-17 | pictured numeric output string overflow |
-18 | parsed string overflow |
-19 | definition name too long |
-20 | write to a read-only location |
-21 | unsupported operation |
| (e.g., AT-XY on a too-dumb terminal) |
-22 | control structure mismatch |
-23 | address alignment exception |
-24 | invalid numeric argument |
-25 | return stack imbalance |
-26 | loop parameters unavailable |
-27 | invalid recursion |
-28 | user interrupt |
-29 | compiler nesting |
-30 | obsolescent feature |
-31 | >BODY used on non-CREATEd definition |
-32 | invalid name argument (e.g., TO name) |
-33 | block read exception |
-34 | block write exception |
-35 | invalid block number |
-36 | invalid file position |
-37 | file I/O exception |
-38 | non-existent file |
-39 | unexpected end of file |
|
|
|
|
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
- no additional requirements.
9.4.1.3 Other system documentation
- no additional requirements.
9.4.2 Program documentation
- no additional requirements.
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