參閱(See): A.9
選用的例外詞集(The optional Exception word set)
參閱(See): A.9.3
附加的使用需求(Additional usage requirements)
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.
如果 File-Access 或 Memory-Allocation 詞集被實作, 建議 ior 使用位於系統 THROW 值中的非零值, 如上所定義. 在一個作業系統環境中, 有時可能由於作業系統例外碼範圍的偏見 而達不到在 THROW 的範圍內.
If the File-Access or Memory-Allocation word sets are implemented, it is recommended that the non-zero values of ior lie within the range of system THROW values, as defined above. In an operating-system environment, this can sometimes be accomplished by biasing the range of operating-system exception-codes to fall within the THROW range.
程式必須不將 THROW 的值範圍設定成 {-4095...-1} 來使用.
Programs shall not define values for use with THROW in the range {-4095...-1}.
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.
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.
Append table 9.1 to table 3.5.
參閱(See): 3.2.6
環境的詢問(Environmental queries)
表格 9.1 - 環境詢問字串
字串 值 資料型別 常數? 意義 ------ --------------- --------- ------- EXCEPTION flag no 例外詞集存在 EXCEPTION-EXT flag no 例外延伸詞集存在
Table 9.1 - Environmental query strings
String Value data type Constant? Meaning ------ --------------- --------- ------- EXCEPTION flag no Exception word set present EXCEPTION-EXT flag no Exception extensions word set present
A system choosing to execute THROW when detecting one of the ambiguous conditions listed in table 9.3.6 shall use the throw code listed there.
參閱(See): 3.4.4
在一個模稜兩可的情況時可能的動作(Possible actions on an ambiguous condition)
表格 9.2 - THROW 碼分配
碼 保留目的
---- ------------
-1 ABORT
-2 ABORT"
-3 堆疊溢位
-4 堆疊不足
-5 返回堆疊溢位
-6 返回堆疊不足
-7 在執行時, do-loops 的迴圈太深
-8 詞典溢位
-9 不正確的記憶體位址
-10 除以零
-11 結果超過範圍
-12 參數型別不合
-13 未定義詞
-14 解譯一個編譯限定詞
-15 不正確的 FORGET
-16 嘗試使用一個零長度的字串為名稱
-17 書寫數字輸出字串溢位
-18 分析過的字串溢位
-19 定義名稱太長
-20 寫入到一個唯讀的位置
-21 未支援的操作 (例如, 在一個太笨的終端機使用 AT-XY)
-22 控制結構不合
-23 位址對齊例外
-24 不正確的數字參數
-25 不平衡的返回堆疊
-26 未提供迴圈參數
-27 不正確的遞迴
-28 使用者中斷
-29 編譯器巢狀
-30 過期的特色
-31 將 >BODY 使用於不是由 CREATE 造出的定義
-32 不正確的名稱參數 (例如, TO xxx)
-33 區塊讀取例外
-34 區塊寫入例外
-35 不正確的區塊號碼
-36 不正確的檔案位置
-37 檔案輸出入例外
-38 不存在的檔案
-39 非預期的檔案結束
-40 浮點運算轉換時, 不正確的 BASE
-41 精確度的損失
-42 浮點運算除以零
-43 浮點運算結果超過範圍
-44 浮點運算堆疊溢位
-45 浮點運算堆疊不足
-46 浮點運算參數不正確
-47 編譯詞列表被刪除
-48 不正確的 POSTPONE
-49 搜尋順序溢位
-50 搜尋順序不足
-51 編譯詞列表被改變
-52 流程控制堆疊溢位
-53 例外堆疊溢位
-54 浮點運算不足
-55 浮點運算未判定的錯誤
-56 QUIT
-57 在傳送或接收一個字元時發生例外
-58 [IF], [ELSE], 或 [THEN] 的例外
Table 9.2 - THROW code assignments
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 xxx)
-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
-40 invalid BASE for floating point conversion
-41 loss of precision
-42 floating-point divide by zero
-43 floating-point result out of range
-44 floating-point stack overflow
-45 floating-point stack underflow
-46 floating-point invalid argument
-47 compilation word list deleted
-48 invalid POSTPONE
-49 search-order overflow
-50 search-order underflow
-51 compilation word list changed
-52 control-flow stack overflow
-53 exception stack overflow
-54 floating-point underflow
-55 floating-point unidentified fault
-56 QUIT
-57 exception in sending or receiving a character
-58 [IF], [ELSE], or [THEN] exception
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).
當一個 THROW 將控制權傳回給一個 CATCH 時, 系統必須不只反巢狀定義, 也要將存在的 local 和輸入來源規格反巢狀, 來讓系統回到它的適當狀態來繼續執行 CATCH.
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.
參閱(See): A.9.3.6
例外處理(Exception handling)
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.
措辭 從例外延伸詞集提供 name(s) 必須被加到任何提供部分例外延伸詞集的標準系統的描述之中.
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.
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.
措辭 需要例外延伸詞集中的 name(s) 必須被加到任何需要系統提供部分例外延伸詞集的標準程式的描述之中.
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.1.0875 CATCH ( i*x xt -- j*x 0 | i*x n )
將一個例外框架堆入在例外堆疊上, 並且執行例外代碼 xt (跟用 EXECUTE 一樣) 在這種方式下, 如果在 xt 執行時, 執行 THROW 時, 控制權可以被傳送成正好在 CATCH 執行之後.
如果 xt 的執行正常地完成 (就是被 CATCH 堆入的例外框架並未被 THROW 取出) 取出這個例外框架, 並且傳回零在資料堆疊上, 在任何將被 xt EXECUTE 傳回的堆疊元素之上. 在其他方面的執行語義部分是由 THROW 所給予的.
9.6.1.0875 CATCH ( i*x xt -- j*x 0 | i*x n )
Push an exception frame on the exception stack and then execute the execution token xt (as with EXECUTE) in such a way that control can be transferred to a point just after CATCH if THROW is executed during the execution of xt.
If the execution of xt completes normally (i.e., the exception frame pushed by this CATCH is not popped by an execution of THROW) pop the exception frame and return zero on top of the data stack, above whatever stack items would have been returned by xt EXECUTE. Otherwise, the remainder of the execution semantics are given by THROW.
9.6.1.2275 THROW ( k*x n -- k*x | i*x n )
如果 n 的任何位元非零, 從例外堆疊取出最上方的例外框架, 隨著任何在這框架之上的返回堆疊上的任何事物. 然後在使用對應的 CATCH 之前, 回存輸入來源規格, 並調整所有由這標準定義的堆疊的深度, 因此它們將會跟存入在例外框架上的深度相同. (由於 i 是給對應的 CATCH 的輸入參數, i 是相同的數目), 將 n 放置於資料堆疊的最上方, 並且傳送控制權在 CATCH 堆入例外框架的那一點之後.
如果堆疊的上方是非零值, 並且沒有例外框架在例外堆疊上, 行動如下:
如果 n 是一個負一(-1), 進行 6.1.0670 ABORT 的功能 (在核心詞集的 ABORT 版本), 不顯示訊息.
如果 n 是負二, 進行 6.1.0680 ABORT" 的功能 (在核心詞集的 ABORT" 版本), 顯示產生 THROW 的 ABORT" 相關的字元 ccc.
否則, 系統可以顯示一個實作相依的訊息, 給出有關於 THROW 碼 n 的有關情況的訊息. 然後, 系統必須進行 6.1.0670 ABORT 的功能 (在核心詞集的 ABORT 版本).
9.6.1.2275 THROW ( k*x n -- k*x | i*x n )
If any bits of n are non-zero, pop the topmost exception frame from the exception stack, along with everything on the return stack above that frame. Then restore the input source specification in use before the corresponding CATCH and adjust the depths of all stacks defined by this Standard so that they are the same as the depths saved in the exception frame (i is the same number as the i in the input arguments to the corresponding CATCH), put n on top of the data stack, and transfer control to a point just after the CATCH that pushed that exception frame.
If the top of the stack is non zero and there is no exception frame on the exception stack, the behavior is as follows:
If n is minus-one (-1), perform the function of 6.1.0670 ABORT (the version of ABORT in the Core word set), displaying no message.
If n is minus-two, perform the function of 6.1.0680 ABORT" (the version of ABORT" in the Core word set), displaying the characters ccc associated with the ABORT" that generated the THROW.
Otherwise, the system may display an implementation-dependent message giving information about the condition associated with the THROW code n. Subsequently, the system shall perform the function of 6.1.0670 ABORT (the version of ABORT in the Core word set).
See: A.9.6.1.2275
THROW
9.6.2.0670 ABORT 延伸 6.1.0670 ABORT 的語義成:
( i*x -- ) ( R: j*x -- )
進行 THROW 的 -1 功能.
9.6.2.0670 ABORT Extend the semantics of 6.1.0670 ABORT to be:
( i*x -- ) ( R: j*x -- )
Perform the function of -1 THROW .
9.6.2.0680 ABORT" 延伸 6.1.0680 ABORT" 的語義成:
解譯: 這個詞的解譯語義是未定義的.
編譯: ( "ccc<quote>" -- )
分析由一個 " (雙引號) 分界的 ccc. 將下列給予的執行語義加進目前的定義.
執行時期: ( i*x x1 -- | i*x ) ( R: j*x -- | j*x )
從堆疊移除 x1. 如果 x1 的任何位元非零, 進行 THROW -2 的功能, 如果在例外堆疊上沒有例外框架時, 顯示 ccc.
參閱: 3.4.1 分析
9.6.2.0680 ABORT"
Extend the semantics of 6.1.0680 ABORT" to be:
Interpretation: Interpretation semantics for this word are undefined.
Compilation: ( "ccc<quote>" -- )
Parse ccc delimited by a " (double-quote). Append the run-time semantics given below to the current definition.
Run-time: ( i*x x1 -- | i*x ) ( R: j*x -- | j*x )
Remove x1 from the stack. If any bit of x1 is not zero, perform the function of -2 THROW, displaying ccc if there is no exception frame on the exception stack.
See: 3.4.1
Parsing
內容列表(Table of Contents)
下一章(Next Section)