3 Usage requirements

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.

3.1 Data types

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.

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.

3.1.1 Data-type relationships

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.

Any Forth definition that accepts an argument of type i shall also accept an argument that is a subtype of i.

3.1.2 Character types

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.

The characters provided by a system shall include the graphic characters {32..126}, which represent graphic forms as shown in table 3.2.

3.1.2.1 Graphic characters

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.

3.1.2.2 Control characters

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.

Table 3.1 - Data types

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 May be either a signed number or an unsigned number depending on context.

2 May be either a double-cell signed number or a double-cell unsigned number depending on context.

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.


Table 3.2 - Standard graphic characters
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      ~       ~

3.1.3 Single-cell types

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.

3.1.3.1 Flags

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.

3.1.3.2 Integers

The implementation-defined range of signed integers shall include {-32767..+32767}.

The implementation-defined range of non-negative integers shall include {0..32767}.

The implementation-defined range of unsigned integers shall include {0..65535}.

3.1.3.3 Addresses

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.

3.1.3.4 Counted strings

A counted string in memory is identified by the address (c-addr) of its length character.

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.

3.1.3.5 Execution tokens

Different definitions may have the same execution token if the definitions are equivalent.

3.1.4 Cell-pair types

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.

3.1.4.1 Double-cell integers

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.

The implementation-defined range of double-cell signed integers shall include {-2147483647..+2147483647}.

The implementation-defined range of double-cell non-negative integers shall include {0..2147483647}.

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.

3.1.4.2 Character strings

A string is specified by a cell pair (c-addr u) representing its starting address and length in characters.

3.1.5 System types

The system data types specify permitted word combinations during compilation and execution.

3.1.5.1 System-compilation types

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.

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.

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.

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.

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.

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.

3.1.5.2 System-execution types

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.

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.

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.

3.2 The implementation environment

3.2.1 Numbers

3.2.1.1 Internal number representation

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.

Table of Contents
Next Section