A system shall provide all of the words defined in 6.1 Core Words. It may also provide any words defined in the optional word sets and extensions word sets. No standard word provided by a system shall alter the system state in a way that changes the effect of execution of any other standard word except as provided in this Standard. A system may contain non-standard extensions, provided that they are consistent with the requirements of this Standard.
一個系統的實作可以使用在標準的範圍之外的詞和技術.
The implementation of a system may use words and techniques outside the scope of this Standard.
一個系統不需要以可執行的格式提供所有詞. 實作可以只以原始碼格式提供定義, 包括在核心詞集中的定義詞. 如果是這種情形, 將這些定義加進詞典的機制是由實作自訂的.
A system need not provide all words in executable form. The implementation may provide definitions, including definitions of words in the Core word set, in source form only. If so, the mechanism for adding the definitions to the dictionary is implementation defined.
一個需要系統未定義在標準中的詞或技術的程式是環境相依的.
A program that requires a system to provide words or techniques not defined in this Standard has an environmental dependency.
See: A.3
使用的需求(Usage requirements)
A data type identifies the set of permissible values for a data object. It is not a property of a particular storage location or position on a stack. Moving a data object shall not affect its type.
一個系統不需要資料型別的檢查. 如果遇到一個不正確的資料物件輸入, 將會發生模稜兩可的情況.
No data-type checking is required of a system. An ambiguous condition exists if an incorrectly typed data object is encountered.
表格 3.1 總結了到處使用於標準中的資料型別. 在一個定義的描述中相同型別的多個實例將加上連續的數字字尾來分辨它們.
Table 3.1 summarizes the data types used throughout this Standard. Multiple instances of the same type in the description of a definition are suffixed with a sequence digit subscript to distinguish them.
See: A.3.1
資料型別(Date-types)
Some of the data types are subtypes of other data types. A data type i is a subtype of type j if and only if the members of i are a subset of the members of j. The following list represents the subtype relationships using the phrase i => j to denote i is a subtype of j. The subtype relationship is transitive; if i => j and j => k then i => k:
+n => u => x; +n => n => x; char => +n; a-addr => c-addr => addr => u; flag => x; xt => x; +d => d => xd; +d => ud => xd.
任何接受型別 i 為參數的 Forth 定義也應該同時接受一個 i 的子型別作為參數.
Any Forth definition that accepts an argument of type i shall also accept an argument that is a subtype of i.
Characters shall be at least one address unit wide, contain at least eight bits, and have a size less than or equal to cell size.
由一個系統提供的字元應該包含書寫字元 {32..126}, 它代表的書寫格式顯示於 表格 3.2.
The characters provided by a system shall include the graphic characters {32..126}, which represent graphic forms as shown in table 3.2.
See: A.3.1.2
字元型別(Character types)
一個書寫字元是正常顯示的字元(例如: A, #, &, 6). 這些顯示於 表格 3.2 的數值和書寫文字是直接從 ANS X3.4-1974 (ASCII) and ISO 646-1983, 國際參考版(IRV) 中取用的. 超過十六進位範圍 {20..7E} 的字元圖形格式是實作自訂的. 使用圖形十六進位 24 的程式(貨幣符號) 有環境相依性.
A graphic character is one that is normally displayed (e.g., A, #, &, 6). These values and graphics, shown in table 3.2, are taken directly from ANS X3.4-1974 (ASCII) and ISO 646-1983, International Reference Version (IRV). The graphic forms of characters outside the hex range {20..7E} are implementation-defined. Programs that use the graphic hex 24 (the currency sign) have an environmental dependency.
字元的書寫顯示並不限制到特定的字型或風格. 這裡有書寫格式的範例.
The graphic representation of characters is not restricted to particular type fonts or styles. The graphics here are examples.
All non-graphic characters included in the implementation-defined character set are defined in this Standard as control characters. In particular, the characters {0..31}, which could be included in the implementation-defined character set, are control characters.
需要收發控制字元的程式是環境相依的.
Programs that require the ability to send or receive control characters have an environmental dependency.
符號 資料型別 在堆疊上的大小 ------ --------- ------------- flag 旗標 1 cell true 真值旗標 1 cell false 假值旗標 1 cell char 字元 1 cell n 有號數 1 cell +n 非負整數 1 cell u 無號數 1 cell n|u 1 數字 1 cell x 未指定的單元 1 cell xt 執行標記 1 cell addr 位置 1 cell a-addr 對齊的位置 1 cell c-addr 字元對對齊的位置 1 cell d 雙單元有號數 2 cells +d 雙單元非負整數 2 cells ud 雙單元無號數 2 cells d|ud 2 雙單元數 2 cells xd 未指定的單元組 2 cells colon-sys 定義編譯 依實作而定 do-sys do-loop 結構 依實作而定 case-sys CASE 結構 依實作而定 of-sys OF 結構 依實作而定 orig 流程控制起始 依實作而定 dest 流程控制目的地 依實作而定 loop-sys loop 控制參數 依實作而定 nest-sys 定義呼叫 依實作而定 i*x, j*x, k*x 3 任何資料型別 0 或多個 cells
Symbol Data type Size on stack ------ --------- ------------- flag flag 1 cell true true flag 1 cell false false flag 1 cell char character 1 cell n signed number 1 cell +n non-negative number 1 cell u unsigned number 1 cell n|u 1 number 1 cell x unspecified cell 1 cell xt execution token 1 cell addr address 1 cell a-addr aligned address 1 cell c-addr character-aligned address 1 cell d double-cell signed number 2 cells +d double-cell non-negative number 2 cells ud double-cell unsigned number 2 cells d|ud 2 double-cell number 2 cells xd unspecified cell pair 2 cells colon-sys definition compilation implementation dependent do-sys do-loop structures implementation dependent case-sys CASE structures implementation dependent of-sys OF structures implementation dependent orig control-flow origins implementation dependent dest control-flow destinations implementation dependent loop-sys loop-control parameters implementation dependent nest-sys definition calls implementation dependent i*x, j*x, k*x 3 any data type 0 or more cells
依上下文 1 可以是一個有號數或是一個無號數.
1 May be either a signed number or an unsigned number depending on context.
依上下文 2 可以是一個雙單元有號數或是一個雙單元無號數.
2 May be either a double-cell signed number or a double-cell unsigned number depending on context.
3 可以是一個未定型別的堆疊未定記錄數字, 使用的範例請參閱 6.1.1370 EXECUTE, 6.1.2050 QUIT.
3 May be an undetermined number of stack entries of unspecified type. For examples of use, see 6.1.1370 EXECUTE, 6.1.2050 QUIT.
See: 11.3.1
資料型別(Data types), 12.3.1
資料型別(Data types), 14.3.1
資料型別(Data types), 16.3.1
資料型別(Data types).
Hex IRV ASCII
--- --- -----
20
21 ! !
22 " "
23 # #
24 ? $
25 % %
26 & &
27 ' '
28 ( (
29 ) )
2A * *
2B + +
2C , ,
2D - -
2E . .
2F / /
30 0 0
31 1 1
32 2 2
33 3 3
34 4 4
35 5 5
36 6 6
37 7 7
38 8 8
39 9 9
3A : :
3B ; ;
3C < <
3D = =
3E > >
3F ? ?
40 @ @
41 A A
42 B B
43 C C
44 D D
45 E E
46 F F
47 G G
48 H H
49 I I
4A J J
4B K K
4C L L
4D M M
4E N N
4F O O
50 P P
51 Q Q
52 R R
53 S S
54 T T
55 U U
56 V V
57 W W
58 X X
59 Y Y
5A Z Z
5B [ [
5C \ \
5D ] ]
5E ^ ^
5F _ _
60 ` `
61 a a
62 b b
63 c c
64 d d
65 e e
66 f f
67 g g
68 h h
69 i i
6A j j
6B k k
6C l l
6D m m
6E n n
6F o o
70 p p
71 q q
72 r r
73 s s
74 t t
75 u u
76 v v
77 w w
78 x x
79 y y
7A z z
7B { {
7C | |
7D } }
7E ~ ~
The implementation-defined fixed size of a cell is specified in address units and the corresponding number of bits. See E.2 Hardware peculiarities.
單元必須至少一個位置單位寬, 並且包含至少十六位元. 一個單元的大小必須是一個字元的完整的倍數大小. 資料堆疊元素、返回堆疊元素、位址、執行標記、旗標、和整數都是一個單元寬.
Cells shall be at least one address unit wide and contain at least sixteen bits. The size of a cell shall be an integral multiple of the size of a character. Data-stack elements, return-stack elements, addresses, execution tokens, flags, and integers are one cell wide.
參閱(See): A.3.1.3
單一單元型別(Single-cell types)
Flags may have one of two logical states, true or false. Programs that use flags as arithmetic operands have an environmental dependency.
一個由標準詞傳回的真旗標必須是一個全部位元設定的單一單元值. 一個由標準詞傳回的假旗標必須是一個全部位元清除的單一單元值.
A true flag returned by a standard word shall be a single-cell value with all bits set. A false flag returned by a standard word shall be a single-cell value with all bits clear.
參閱(See): A.3.1.3.1
旗標(Flags)
The implementation-defined range of signed integers shall include {-32767..+32767}.
實作自訂的非負整數必須包含 {0..+32767}.
The implementation-defined range of non-negative integers shall include {0..32767}.
實作自訂的無號整數必須包含 {0..65535}.
The implementation-defined range of unsigned integers shall include {0..65535}.
參閱(See): A.3.1.3.2
整數(Integers)
An address identifies a location in data space with a size of one address unit, which a program may fetch from or store into except for the restrictions established in this Standard. The size of an address unit is specified in bits. Each distinct address value identifies exactly one such storage element. See 3.3.3 Data space.
字元對齊位址的集合、一個字元可以被存取的位址是一個實作自訂的所有位址的子集合. 增加一個字元大小到一個字元對齊位址必須產生另一個字元對齊位址.
The set of character-aligned addresses, addresses at which a character can be accessed, is an implementation-defined subset of all addresses. Adding the size of a character to a character-aligned address shall produce another character-aligned address.
對齊位址的集合是一個實作自訂的字元對齊位址的子集合. 增加一個單元大小到一個對齊位址必須產生另一個對齊位址.
The set of aligned addresses is an implementation-defined subset of character-aligned addresses. Adding the size of a cell to an aligned address shall produce another aligned address.
參閱(See): A.3.1.3.3
位址(Addresses)
A counted string in memory is identified by the address (c-addr) of its length character.
一個計數字串的長度字元位址必須包含一個二進位表現的資料字元數目, 在零與實作自訂的計數字串最大長度之間. 一個計數字串的最大長度必須至少 255.
The length character of a counted string shall contain a binary representation of the number of data characters, between zero and the implementation-defined maximum length for a counted string. The maximum length of a counted string shall be at least 255.
參閱(See): A.3.1.3.4
計數字串(Counted strings)
Different definitions may have the same execution token if the definitions are equivalent.
參閱(See): A.3.1.3.5
執行代號(Execution tokens)
A cell pair in memory consists of a sequence of two contiguous cells. The cell at the lower address is the first cell, and its address is used to identify the cell pair. Unless otherwise specified, a cell pair on a stack consists of the first cell immediately above the second cell.
參閱(See): A.3.1.4
雙基本單位型別(Cell-pair types)
On the stack, the cell containing the most significant part of a double-cell integer shall be above the cell containing the least significant part.
實作自訂的雙單元有號整數範圍必須包含 {-2147483647..+2147483647}.
The implementation-defined range of double-cell signed integers shall include {-2147483647..+2147483647}.
實作自訂的雙單元非負整數範圍必須包含 {0..2147483647}.
The implementation-defined range of double-cell non-negative integers shall include {0..2147483647}.
實作自訂的雙單元無號整數範圍必須包含 {0..4294967295}. 在堆疊的單一單元無號整數上放置單一單元整數零將會產生一個同值的雙單元無號整數. 參閱: 3.2.1.1 內部數值表示
The implementation-defined range of double-cell unsigned integers shall include {0..4294967295}. Placing the single-cell integer zero on the stack above a single-cell unsigned integer produces a double-cell unsigned integer with the same value. See 3.2.1.1 Internal number representation.
參閱(See): A.3.1.4.1
雙單元整數(Double-cell integers)
A string is specified by a cell pair (c-addr u) representing its starting address and length in characters.
參閱(See): A.3.1.3.4
計數字串(Counted strings)
The system data types specify permitted word combinations during compilation and execution.
These data types denote zero or more items on the control-flow stack (see 3.2.3.2). The possible presence of such items on the data stack means that any items already there shall be unavailable to a program until the control-flow-stack items are consumed.
在標準中符號 colon-sys 代表的是實作相依資料是在開始編譯一個定義時產生, 在結束時被使用掉.
The implementation-dependent data generated upon beginning to compile a definition and consumed at its close is represented by the symbol colon-sys throughout this Standard.
在標準中符號 do-sys 代表的是實作相依資料是在開始編譯一個 do-loop 結構時產生, 在結束時被使用掉, 像是 DO ... LOOP
The implementation-dependent data generated upon beginning to compile a do-loop structure such as DO ... LOOP and consumed at its close is represented by the symbol do-sys throughout this Standard.
在標準中符號 case-sys 代表的是實作相依資料是在開始編譯一個 CASE ... ENDCASE 結構時產生, 在結束時被使用掉.
The implementation-dependent data generated upon beginning to compile a CASE ... ENDCASE structure and consumed at its close is represented by the symbol case-sys throughout this Standard.
在標準中符號 of-sys 代表的是實作相依資料是在開始編譯一個 OF ... ENDOF 結構時產生, 在結束時被使用掉.
The implementation-dependent data generated upon beginning to compile an OF ... ENDOF structure and consumed at its close is represented by the symbol of-sys throughout this Standard.
在標準中符號 orig 和 dest 分別代表執行其他標準流程控制詞時產生和使用的實作相依資料.
The implementation-dependent data generated and consumed by executing the other standard control-flow words is represented by the symbols orig and dest throughout this Standard.
These data types denote zero or more items on the return stack. Their possible presence means that any items already on the return stack shall be unavailable to a program until the system-execution items are consumed.
在標準中符號 nest-sys 代表的是實作相依資料是在開始執行一個定義時產生, 在跳出一個定義時被使用掉.
The implementation-dependent data generated upon beginning to execute a definition and consumed upon exiting it is represented by the symbol nest-sys throughout this Standard.
在標準中符號 loop-sys 代表的是使用來控制 do-loops 執行的實作相依的迴圈控制參數. 迴圈控制參數必須在 do-loop 中可被用來改變這些參數的詞存取, 像是 I, J, LEAVE 和 UNLOOP.
The implementation-dependent loop-control parameters used to control the execution of do-loops are represented by the symbol loop-sys throughout this Standard. Loop-control parameters shall be available inside the do-loop for words that use or change these parameters, words such as I, J, LEAVE and UNLOOP.
See: A.3.2.1
數字(Numbers)
This Standard allows one's complement, two's complement, or sign-magnitude number representations and arithmetic. Arithmetic zero is represented as the value of a single cell with all bits clear.
一個編譯過的文字數字或是在記憶體中數字的表示法是實作自訂的.
The representation of a number as a compiled literal or in memory is implementation dependent.
Numbers shall be represented externally by using characters from the standard character set.
一個數字在內部與外部格式的轉換上必須以下列的方式運作:
Conversion between the internal and external forms of a digit shall behave as follows:
在 BASE 中的數值是數值轉換的基底. 一個數字有一個從零到比目前 BASE 內容小一的數值. 值為零的數字對應到字元 0. 數字的表現處理出自這個字元集, 直到十進位數字九對應到 9 為止. 對於開始於十進位數值十的數字而言, 書寫字元開始於 A. 對應的字元直到十進位三十五為止, 而對應到 Z. 超過這個範圍的數字轉換是實作自訂的.
The value in BASE is the radix for number conversion. A digit has a value ranging from zero to one less than the contents of BASE. The digit with the value zero corresponds to the character 0. This representation of digits proceeds through the character set to the decimal value nine corresponding to the character 9. For digits beginning with the decimal value ten the graphic characters beginning with the character A are used. This correspondence continues up to and including the digit with the decimal value thirty-five which is represented by the character Z. The conversion of digits outside this range is implementation defined.
See: A.3.2.1.2
數字轉換(Digit conversion)
Free-field number display uses the characters described in digit conversion, without leading zeros, in a field the exact size of the converted string plus a trailing space. If a number is zero, the least significant digit is not considered a leading zero. If the number is negative, a leading minus sign is displayed.
數字顯示可以使用圖樣數值輸出字串緩衝區來保存部分轉換的字串(參閱: 3.3.3.6 其他暫時的區域).
Number display may use the pictured numeric output string buffer to hold partially converted strings (see 3.3.3.6 Other transient regions).
Division produces a quotient q and a remainder r by dividing operand a by operand b. Division operations return q, r, or both. The identity b*q + r = a shall hold for all a and b.
當無號整數被除並且餘數不是零時, q 是小於真正的商數的最大整數.
When unsigned integers are divided and the remainder is not zero, q is the largest integer less than the true quotient.
當有號整數被除並且餘數不是零時, 而且 a 和 b 有相同的符號, q 是小於真正的商數的最大整數. 如果只有一個運算元是負數, q 依實作自訂可能為四捨五入到負無限 (底限除法) 或 四捨五入到零(對稱除法) (譯註: 這些是數學專有名詞, 目前沒有參考資料, 因此翻譯必定有錯誤)
When signed integers are divided, the remainder is not zero, and a and b have the same sign, q is the largest integer less than the true quotient. If only one operand is negative, whether q is rounded toward negative infinity (floored division) or rounded towards zero (symmetric division) is implementation defined.
底限除法是餘數攜帶著除數符號或零的整數除法, 而商是四捨五入到它的算術底. 對稱除法是餘數攜帶著被除數符號或零的整數除法, 而商是 四捨五入到零或截去的算術商. 兩者的例子顯示於表格 3.3 和 3.4.
Floored division is integer division in which the remainder carries the sign of the divisor or is zero, and the quotient is rounded to its arithmetic floor. Symmetric division is integer division in which the remainder carries the sign of the dividend or is zero and the quotient is the mathematical quotient rounded towards zero or truncated. Examples of each are shown in tables 3.3 and 3.4.
在運算元符號不同及四捨五入方向考量的情形下, 一個程式應該自行包含所需的除法格式, 而不依靠實作自訂的預設結果, 或是用一個環境相依的合需求的四捨五入方向.
In cases where the operands differ in sign and the rounding direction matters, a program shall either include code generating the desired form of division, not relying on the implementation-defined default result, or have an environmental dependency on the desired rounding direction.
參閱(See): A.3.2.2.1
整數除法(Integer division)
被除數 除數 餘數 商 -------- ------- --------- -------- 10 7 3 1 -10 7 4 -2 10 -7 -4 -2 -10 -7 -3 1
被除數 除數 餘數 商 -------- ------- --------- -------- 10 7 3 1 -10 7 -3 -1 10 -7 3 -1 -10 -7 -3 1
Dividend Divisor Remainder Quotient -------- ------- --------- -------- 10 7 3 1 -10 7 4 -2 10 -7 -4 -2 -10 -7 -3 1
Dividend Divisor Remainder Quotient -------- ------- --------- -------- 10 7 3 1 -10 7 -3 -1 10 -7 3 -1 -10 -7 -3 1
In all integer arithmetic operations, both overflow and underflow shall be ignored. The value returned when either overflow or underflow occurs is implementation defined.
See: A.3.2.2.2
其他整數運算(Other integer operations)
參閱(See): A.3.2.3
堆疊(Stacks)
Objects on the data stack shall be one cell wide.
The control-flow stack is a last-in, first out list whose elements define the permissible matchings of control-flow words and the restrictions imposed on data-stack usage during the compilation of control structures.
在流程控制堆疊上的元素是系統編譯型別.
The elements of the control-flow stack are system-compilation data types.
流程控制堆疊可以, 但不必實際存在於一個實作中. 如果它存在, 它可以是但不必要以使用資料堆疊的方式實作. 流程控制堆疊的格式是實作自訂的. 由於流程控制堆疊可以使用資料堆疊來實作, 放置在在資料堆疊上的元素在對於一個程式來說是必須是暫時無法存取的, 直到流程控制堆疊元素被放置進去及使用之後才可使用.
The control-flow stack may, but need not, physically exist in an implementation. If it does exist, it may be, but need not be, implemented using the data stack. The format of the control-flow stack is implementation defined. Since the control-flow stack may be implemented using the data stack, items placed on the data stack are unavailable to a program after items are placed on the control-flow stack and remain unavailable until the control-flow stack items are removed.
參閱(See): A.3.2.3.2
流程控制堆疊(Control-flow stack)
Items on the return stack shall consist of one or more cells. A system may use the return stack in an implementation-dependent manner during the compilation of definitions, during the execution of do-loops, and for storing run-time nesting information.
一個程式可以使用返回堆疊來作為執行定義時期的暫存空間, 但須遵守下述限制:
A program may use the return stack for temporary storage during the execution of a definition subject to the following restrictions:
參閱(See): A.3.2.3.3
返回堆疊(Return stack)
參閱(See): 1.2.2
排除部分(Exclusions)
The method of selecting the user input device is implementation defined.
標示一個文字輸入行結束的方法是實作自訂的.
The method of indicating the end of an input line of text is implementation defined.
The method of selecting the user output device is implementation defined.
A system need not provide any standard words for accessing mass storage. If a system provides any standard word for accessing mass storage, it shall also implement the Block word set.
The name spaces for ENVIRONMENT? and definitions are disjoint. Names of definitions that are the same as ENVIRONMENT? strings shall not impair the operation of ENVIRONMENT?. Table 3.5 contains the valid input strings and corresponding returned value for inquiring about the programming environment with ENVIRONMENT?.
字串 值 常數? 意義
資料型別
/COUNTED-STRING n yes 一個計數字串的最大大小,
字元為單位
/HOLD n yes 書寫數字字串輸出緩衝區大小,
字元為單位
/PAD n yes PAD 指向的隨機暫存區的大小,
字元為單位
ADDRESS-UNIT-BITS n yes 一個位置單元的大小, 位元為單元
CORE flag no 如果完全的核心詞集存在則為真
(換句話說, 就是不是定義於 5.1.1
的子集)
CORE-EXT flag no 如果完全的核心延伸詞集存在則為真
FLOORED flag yes 如果底限除法是預設方法則為真
MAX-CHAR u yes 在實作自訂的字元集中最大的字元之值
MAX-D d yes 最大可用的有號雙數值
MAX-N n yes 最大可用的有號整數
MAX-U u yes 最大可用的無號整數
MAX-UD ud yes 最大可用的無號雙數值
RETURN-STACK-CELLS n yes 返回堆疊的最大大小,
以單元為單位
STACK-CELLS n yes 資料堆疊的最大大小,
以單元為單位
Table 3.5 - Environmental Query Strings
String Value Constant? Meaning
data type
/COUNTED-STRING n yes maximum size of a counted string,
in characters
/HOLD n yes size of the pictured numeric output
string buffer, in characters
/PAD n yes size of the scratch area pointed to
by PAD, in characters
ADDRESS-UNIT-BITS n yes size of one address unit, in bits
CORE flag no true if complete core word set
present (i.e., not a subset as
defined in 5.1.1)
CORE-EXT flag no true if core extensions word
set present
FLOORED flag yes true if floored division is the default
MAX-CHAR u yes maximum value of any character in the
implementation-defined character set
MAX-D d yes largest usable signed double number
MAX-N n yes largest usable signed integer
MAX-U u yes largest usable unsigned integer
MAX-UD ud yes largest usable unsigned double number
RETURN-STACK-CELLS n yes maximum size of the return stack,
in cells
STACK-CELLS n yes maximum size of the data stack,
in cells
如果一個環境詢問(使用 ENVIRONMENT?) 對應一個字串回應假 (也就是說, 不清楚), 隨後發生而使用相同字串的查詢有可能傳回真. 如果一個詢問對於一個字串傳回真 (也就是說, 知道), 隨後發生而使用相同字串的查詢有必須也傳回真. 如果一個在上面表格的詢問被指派為常數, 並且回應一個值給字串, 用相同字串隨後發生的詢問必須傳回真及相同的值.
If an environmental query (using ENVIRONMENT?) returns false (i.e., unknown) in response to a string, subsequent queries using the same string may return true. If a query returns true (i.e., known) in response to a string, subsequent queries with the same string shall also return true. If a query designated as constant in the above table returns true and a value in response to a string, subsequent queries with the same string shall return true and the same value.
參閱: A.3.2.6
環境詢問, 7.3.1 環境詢問,
8.3.1
環境詢問, 9.3.4 環境詢問,
10.3.2
環境詢問, 11.3.3
環境詢問, 12.3.4
環境詢問, 13.3.2
環境詢問, 14.3.2
環境詢問, 15.3.1
環境詢問, 16.3.2
環境詢問, 17.3
附加的使用需求.
See: A.3.2.6
Environmental queries, 7.3.1
Environmental queries, 8.3.1
Environmental queries, 9.3.4
Environmental queries, 10.3.2
Environmental queries, 11.3.3
Environmental queries, 12.3.4
Environmental queries, 13.3.2
Environmental queries, 14.3.2
Environmental queries, 15.3.1
Environmental queries, 16.3.2
Environmental queries, 17.3
Additional usage requirements.
Forth words are organized into a structure called the dictionary. While the form of this structure is not specified by the Standard, it can be described as consisting of three logical parts: a name space, a code space, and a data space. The logical separation of these parts does not require their physical separation.
一個程式必須不從資料空間之外存取資料. 如果一個程式使用名稱空間或是程式碼空間的位置, 模稜兩可的情況將會存在.
A program shall not fetch from or store into locations outside data space. An ambiguous condition exists if a program addresses name space or code space.
參閱(See): A.3.3 Forth
詞典(The Forth dictionary)
The relationship between name space and data space is implementation dependent.
The structure of a word list is implementation dependent. When duplicate names exist in a word list, the latest-defined duplicate shall be the one found during a search for the name.
Definition names shall contain {1..31} characters. A system may allow or prohibit the creation of definition names containing non-standard characters.
使用小寫的標準定義名字的程式或依靠一個系統大小寫敏感度的程式有環境的相依性.
Programs that use lower case for standard definition names or depend on the case-sensitivity properties of a system have an environmental dependency.
一個程式必須不創造非書寫字元的定義名字.
A program shall not create definition names containing non-graphic characters.
參閱(See): A.3.3.1.2
定義的名字(Definition names)
The relationship between code space and data space is implementation dependent.
Data space is the only logical area of the dictionary for which standard words are provided to allocate and access regions of memory. These regions are: contiguous regions, variables, text-literal regions, input buffers, and other transient regions, each of which is described in the following sections. A program may read from or write into these regions unless otherwise specified.
參閱(See): A.3.3.3
資料空間(Data space)
Most addresses used in ANS Forth are aligned addresses (indicated by a-addr) or character-aligned (indicated by c-addr). ALIGNED, CHAR+, and arithmetic operations can alter the alignment state of an address on the stack. CHAR+ applied to an aligned address returns a character-aligned address that can only be used to access characters. Applying CHAR+ to a character-aligned address produces the succeeding character-aligned address. Adding or subtracting an arbitrary number to an address can produce an unaligned address that shall not be used to fetch or store anything. The only way to find the next aligned address is with ALIGNED. An ambiguous condition exists when @, !, , (comma), +!, 2@, or 2! is used with an address that is not aligned, or when C@, C!, or C, is used with an address that is not character-aligned.
由定義 6.1.1000 CREATE 和 6.1.2410 VARIABLE 創造的詞將會傳回對齊的位址.
The definitions of 6.1.1000 CREATE and 6.1.2410 VARIABLE require that the definitions created by them return aligned addresses.
在定義被編譯後或是 ALIGN 被執行後, 資料空間的指標保證是對齊的.
After definitions are compiled or the word ALIGN is executed the data-space pointer is guaranteed to be aligned.
參閱(See): A.3.3.3.1
位址對齊(Address alignment)
A system guarantees that a region of data space allocated using ALLOT, , (comma), C, (c-comma), and ALIGN shall be contiguous with the last region allocated with one of the above words, unless the restrictions in the following paragraphs apply. The data-space pointer HERE always identifies the beginning of the next data-space region to be allocated. As successive allocations are made, the data-space pointer increases. A program may perform address arithmetic within contiguously allocated regions. The last region of data space allocated using the above operators may be released by allocating a corresponding negatively-sized region using ALLOT, subject to the restrictions of the following paragraphs.
CREATE 建立資料空間中連續區域的開頭部分, 而這個開始位址將會被創造出來的定義傳回. 這個區域將會在編譯下一個定義時結束.
CREATE establishes the beginning of a contiguous region of data space, whose starting address is returned by the CREATEd definition. This region is terminated by compiling the next definition.
由於一個實作是自由地可以配置資料空間來給程式碼使用, 如果定義在配置中被從詞典中加入或移除, 上面的操作詞就不需產生連續的資料空間區域. 如果一個被釋放的記憶體中包含定義時, 就會產生模稜兩可的情況.
Since an implementation is free to allocate data space for use by code, the above operators need not produce contiguous regions of data space if definitions are added to or removed from the dictionary between allocations. An ambiguous condition exists if deallocated memory contains definitions.
參閱(See): A.3.3.3.2
連續區域(Contiguous regions)
The region allocated for a variable may be non-contiguous with regions subsequently allocated with , (comma) or ALLOT. For example, in:
VARIABLE X 1 CELLS ALLOT
區域 X 和被 ALLOT 配置的區域可以不連續.
the region X and the region ALLOTted could be non-contiguous.
一些系統提供的變數, 像是 STATE 是被限制為唯讀的.
Some system-provided variables, such as STATE, are restricted to read-only access.
The text-literal regions, specified by strings compiled with S" and C", may be read-only.
一個程式必須不寫入 S" 和 C" 造出的文字區域, 也不能寫入唯讀的系統變數或唯讀的暫時的區域. 當一個程式嘗試寫入一個唯讀的區域時, 就會產生模稜兩可的情況.
A program shall not store into the text-literal regions created by S" and C" nor into any read-only system variable or read-only transient regions. An ambiguous condition exists when a program attempts to store into read-only regions.
The address, length, and content of the input buffer may be transient. A program shall not write into the input buffer. In the absence of any optional word sets providing alternative input sources, the input buffer is either the terminal-input buffer, used by QUIT to hold one line from the user input device, or a buffer specified by EVALUATE. In all cases, SOURCE returns the beginning address and length in characters of the current input buffer.
終端機輸入緩衝區的最小數量是 80 個字元.
The minimum size of the terminal-input buffer shall be 80 characters.
只有直到文字解譯器做完 I/O 來重填輸入緩衝區或是輸入來源改變之後, 由 SOURCE 傳回的位址和長度、由 PARSE 傳回的字串、和直接計算輸入緩衝區位址才會是正確的.
The address and length returned by SOURCE, the string returned by PARSE, and directly computed input-buffer addresses are valid only until the text interpreter does I/O to refill the input buffer or the input source is changed.
一個程式可以在這個標準強制施行的限制下透過改變 >IN 的內容來修改分析區的大小. 例如, 如果 >IN 的內容在一個分析的操作進行之前被儲存, 並且以後再回存, 被分析過的文字將可以被稍後的分析操作再一次使用. 允許使用這種方法來重定義的範圍是依據輸入來源(參閱 7.3.3 區塊緩衝區域和 11.3.4 輸入來源).
A program may modify the size of the parse area by changing the contents of >IN within the limits imposed by this Standard. For example, if the contents of >IN are saved before a parsing operation and restored afterwards, the text that was parsed will be available again for subsequent parsing operations. The extent of permissible repositioning using this method depends on the input source (see 7.3.3 Block buffer regions and 11.3.4 Input source).
一個程式可以直接使用由 SOURCE 傳回的位址和長度來檢視輸入緩衝區; 在輸入緩衝區中分析區開始的位置是以 >IN 的數目來定位. 這些數值是在有限的時間內正確的. 如果一個程式修改輸入緩衝區的內容將會產生模稜兩可的情況.
A program may directly examine the input buffer using its address and length as returned by SOURCE; the beginning of the parse area within the input buffer is indexed by the number in >IN. The values are valid for a limited time. An ambiguous condition exists if a program modifies the contents of the input buffer.
參閱(See): RFI 0006
寫入到輸入緩衝區(Writing to Input Buffers)
The data space regions identified by PAD, WORD, and #> (the pictured numeric output string buffer) may be transient. Their addresses and contents may become invalid after:
由 WORD 和 #> 辨別的之前的區域內容可以在每次使用這些詞之後變成不正確. 此外由 WORD 和 #> 傳回的區域可以在記憶體中重疊. 因此使用這些詞之一可能破壞較早由不同詞傳回的區域. 其他建造書寫數字輸出字串的詞, (<#, #, #S, 和 HOLD) 也可以修改這些區域的內容. 顯示數字的詞可以使用書寫數字輸出詞來實作. 因此 . (小數點), .R, .S, ?, D., D.R, U., 和 U.R 也可能破壞這些區域.
The previous contents of the regions identified by WORD and #> may be invalid after each use of these words. Further, the regions returned by WORD and #> may overlap in memory. Consequently, use of one of these words can corrupt a region returned earlier by a different word. The other words that construct pictured numeric output strings (<#, #, #S, and HOLD) may also modify the contents of these regions. Words that display numbers may be implemented using pictured numeric output words. Consequently, . (dot), .R, .S, ?, D., D.R, U., and U.R could also corrupt the regions.
由 PAD 傳回位址的隨機暫存區的大小必須至少是 84 個字元. 由 PAD 傳回位址的區域的內容是設計完全給使用者控制使用的: 沒有定義於這個標準中的詞在這個區域中放置任何事物, 雖然改變描述於 3.3.3.2 資料空間配置的連續區域可能改變由 PAD 回傳的位址. 一個實作提供的不標準詞可以使用 PAD, 但是這樣的使用必須有文件.
The size of the scratch area whose address is returned by PAD shall be at least 84 characters. The contents of the region addressed by PAD are intended to be under the complete control of the user: no words defined in this Standard place anything in the region, although changing data-space allocations as described in 3.3.3.2 Contiguous regions may change the address returned by PAD. Non-standard words provided by an implementation may use PAD, but such use shall be documented.
由 WORD 識別的區域大小必須至少為 33 個字元.
The size of the region identified by WORD shall be at least 33 characters.
書寫數字輸出字串緩衝區的大小必須至少 (2 * n) + 2 個字元, 其中的 n 是一個單元中的位元數量. 將它認為是有一個不變的存取參數的固定區域的程式有一個環境相依性.
The size of the pictured numeric output string buffer shall be at least (2*n) + 2 characters, where n is the number of bits in a cell. Programs that consider it a fixed area with unchanging access parameters have an environmental dependency.
參閱(See): A.3.3.3.6
其他暫時的區域(Other transient regions), 11.3.5
其他暫時的區域(Other transient regions).
Upon start-up, a system shall be able to interpret, as described by 6.1.2050 QUIT, Forth source code received interactively from a user input device.
這樣的交談式系統通常供給一個 提示符號 來表示它們收受一個使用者的需求並且對它進行運作. 實作自訂的 Forth 提示符號必須包含用大寫或小寫不同組合的這個字 OK.
Such interactive systems usually furnish a prompt indicating that they have accepted a user request and acted on it. The implementation-defined Forth prompt should contain the word OK in some combination of upper or lower case.
文字的解譯 (參閱: 6.1.1360 EVALUATE 和 6.1.2050 QUIT) 必須重複下列的步驟, 支到分析區是空的或是一個模稜兩可的情況存在:
Text interpretation (see 6.1.1360 EVALUATE and 6.1.2050 QUIT) shall repeat the following steps until either the parse area is empty or an ambiguous condition exists:
a) 跳過開頭的空白並且分析一個名字 (參閱 3.4.1);
b) 在詞典名稱空間中尋找 (參閱 3.4.2). 如果一個定義名稱符合則這個字串就被找到了:
c) 如果對應到這個字串的定義名稱找不到, 嘗試將這個字串轉換成一個數字 (參閱 3.4.1.3). 如果成功:
d) 如果不成功, 一個模稜兩可的情況將會出現 (參閱 3.4.4).
a) Skip leading spaces and parse a name (see 3.4.1);
b) Search the dictionary name space (see 3.4.2). If a definition name matching the string is found:
c) If a definition name matching the string is not found, attempt to convert the string to a number (see 3.4.1.3). If successful:
d) If unsuccessful, an ambiguous condition exists (see 3.4.4).
Unless otherwise noted, the number of characters parsed may be from zero to the implementation-defined maximum length of a counted string.
如果分析區是空的, 換句話說, 當在 >IN 內的數字是等於輸入緩衝區的長度, 或是除了分界符號之外不包含其他字元時, 被選擇的字串就是空的. 在其他情形下, 被選擇的字串是從分析區的下一個字元開始, 這個字串是由 >IN 的內容索引的. 如果 >IN 中的數目大於輸入緩衝區的大小時, 一個模稜兩可的情況存在.
If the parse area is empty, i.e., when the number in >IN is equal to the length of the input buffer, or contains no characters other than delimiters, the selected string is empty. Otherwise, the selected string begins with the next character in the parse area, which is the character indexed by the contents of >IN. An ambiguous condition exists if the number in >IN is greater than the size of the input buffer.
如果在選擇的字串開始之後有一個分界符號存在, 這個字串繼續成長到包含這個第一個分界符號字元, 而 >IN 中的數目被改成索引到正好超過這個分界符號, 像這樣來從分析區移除分析過的字元及分界符號. 否則, 這個字串繼續成長到包含這個分析區中的最後一個字元, 並且 >IN 中的數目被改變這個輸入緩衝區的長度, 像這樣來清空分析區.
If delimiter characters are present in the parse area after the beginning of the selected string, the string continues up to and including the character just before the first such delimiter, and the number in >IN is changed to index immediately past that delimiter, thus removing the parsed characters and the delimiter from the parse area. Otherwise, the string continues up to and including the last character in the parse area, and the number in >IN is changed to the length of the input buffer, thus emptying the parse area.
分析可以改變 >IN 的內容, 但是必須不影響輸入緩衝區的內容. 特別是, 如果在 >IN 中的值在開始分析前被儲存, 在分析後立即重設 >IN 成儲存的值將必須能回存分析區而不損失任何資料.
Parsing may change the contents of >IN, but shall not affect the contents of the input buffer. Specifically, if the value in >IN is saved before starting the parse, resetting >IN to that value immediately after the parse shall restore the parse area without loss of data.
If the delimiter is the space character, hex 20 (BL), control characters may be treated as delimiters. The set of conditions, if any, under which a space delimiter matches control characters is implementation defined.
要跳過開頭的分界符號是為了在分析之前跳過零或多個連續的分界符號.
To skip leading delimiters is to pass by zero or more contiguous delimiters in the parse area before parsing.
Forth has a simple, operator-ordered syntax. The phrase A B C returns values as if A were executed first, then B and finally C. Words that cause deviations from this linear flow of control are called control-flow words. Combinations of control-flow words whose stack effects are compatible form control-flow structures. Examples of typical use are given for each control-flow word in Annex A.
Forth 的語法是可延伸的; 例如, 新的流程控制詞可以用已經存在的專有名詞來定義.
Forth syntax is extensible; for example, new control-flow words can be defined in terms of existing ones.
這標準不需要一個語法或程式建造檢查器.
This Standard does not require a syntax or program-construct checker.
When converting input numbers, the text interpreter shall recognize both positive and negative numbers, with a negative number represented by a single minus sign, the character -, preceding the digits. The value in BASE is the radix for number conversion.
A string matches a definition name if each character in the string matches the corresponding character in the string used as the definition name when the definition was created. The case sensitivity (whether or not the upper-case letters match the lower-case letters) is implementation defined. A system may be either case sensitive, treating upper- and lower-case letters as different and not matching, or case insensitive, ignoring differences in case while searching.
在字元延伸集裡的字母字元的大小寫字元匹配是實作自訂的, 例如國際重音字元.
The matching of upper- and lower-case letters with alphabetic characters in character set extensions such as accented international characters is implementation defined.
一個系統必須能夠找出這個標準的定義名稱, 當它們是以大寫字元拼出時.
A system shall be capable of finding the definition names defined by this Standard when they are spelled with upper-case letters.
The semantics of a Forth definition are implemented by machine code or a sequence of execution tokens or other representations. They are largely specified by the stack notation in the glossary entries, which shows what values shall be consumed and produced. The prose in each glossary entry further specifies the definition's behavior.
每一個 Forth 定義可以有數個行為, 描述在下列的章節. 專有名詞 初始語義 和 執行語義 反映到定義的片斷, 並且只在它們出現的每一個詞彙記錄中有意義.
Each Forth definition may have several behaviors, described in the following sections. The terms initiation semantics and run-time semantics refer to definition fragments, and have meaning only within the individual glossary entries where they appear.
參閱(See): A.3.4.3
語義(Semantics), RFI
0005.
The execution semantics of each Forth definition are specified in an Execution: section of its glossary entry. When a definition has only one specified behavior, the label is omitted.
當定義被編譯成執行時, 執行動作可以隱含地出現, 或是當定義的執行標記被傳給 EXECUTE 時, 就是明白地執行. 句子構造正確的定義執行的語義如果是不在標準指定中時, 就是實作相依的.
Execution may occur implicitly, when the definition into which it has been compiled is executed, or explicitly, when its execution token is passed to EXECUTE. The execution semantics of a syntactically correct definition under conditions other than those specified in this Standard are implementation dependent.
定義詞的詞彙記錄包含給新的定義的執行語義是包含在 名稱 執行: 節.
Glossary entries for defining words include the execution semantics for the new definition in a name Execution: section.
Unless otherwise specified in an Interpretation: section of the glossary entry, the interpretation semantics of a Forth definition are its execution semantics.
一個系統必須在解譯模式中有能力執行所有的核心詞集和任何選用詞集或詞集延伸集的定義, 而它們的解譯語義是定義在標準中.
A system shall be capable of executing, in interpretation state, all of the definitions from the Core word set and any definitions included from the optional word sets or word set extensions whose interpretation semantics are defined by this Standard.
一個系統必須在解譯模式中有能力執行任何根據 3. 使用需求 所新創造的詞.
A system shall be capable of executing, in interpretation state, any new definitions created in accordance with 3. Usage requirements.
參閱(See): A.3.4.3.2
解譯語義(Interpretation semantics)
除非特別指定在一個詞彙記錄中的 編譯: 小節中, 否則一個 Forth 定義的編譯語義必須是把它的執行語義加進目前定義的執行語義.
Unless otherwise specified in a Compilation: section of the glossary entry, the compilation semantics of a Forth definition shall be to append its execution semantics to the execution semantics of the current definition.
參閱(See): RFI 0007 在 "即時性" 和
"特別編譯語義" 之間的差別(Distinction between immediacy and special
compilation semantics).
When an ambiguous condition exists, a system may take one or more of the following actions:
對於一個特別的模稜兩可的狀況的回應不需在所有的情況下都一樣.
The response to a particular ambiguous condition need not be the same under all circumstances.
A program shall not attempt to nest compilation of definitions.
在編譯目前的定義時, 一個程式必須不執行任何的定義詞, :NONAME, 或任何配置詞典資料空間的定義. 目前的編譯可以使用 [ (left-bracket) 來暫停, 並且使用 ] (right-bracket) 來再啟動編譯. 當編譯目前的定義暫停時, 一個程式必須不執行任何的定義詞, :NONAME, 或任何配置詞典資料空間的定義.
During the compilation of the current definition, a program shall not execute any defining word, :NONAME, or any definition that allocates dictionary data space. The compilation of the current definition may be suspended using [ (left-bracket) and resumed using ] (right-bracket). While the compilation of the current definition is suspended, a program shall not execute any defining word, :NONAME, or any definition that allocates dictionary data space.
See: A.3.4.5
編譯(Compilation)
內容列表(Table of Contents)
下一章(Next Section)