In Gforth 1.0 we switched to a new word header layout. For a detailed description, read: Bernd Paysan and M. Anton Ertl. The new Gforth header. In 35th EuroForth Conference, pages 5-20, 2019. Since this paper was published, xt and nt have been changed to point to the parameter field, like the body, but otherwise it is still up-to-date.
This section explains just the data structure and the words used to access it. A header has the following fields:
name >f+c >link >cfa >namehm >body
Currently Gforth has the names shown above for
getting from the xt/nt/body to the field, but apart from the standard
>body
they are not stable Gforth words. Instead, we provide
access words. Note that the documented access words have survived the
reorganization of the header layout.
Some of the words expect an nt, some expect an xt. Given that both nt and xt point to the body of a word, what is the difference? For most words, the xt and nt use the same header, and with nt=xt, they point to the same place. However, for a synonym (see Aliases) there is a difference; consider the example
create x synonym y x synonym z y
In this case the nt of z
points to the body of z
, while
the xt of z
points to the body of x
. Words defined with
alias
or forward
(see Forward) also have different
nts and xts.
The name field is variable-length and is accessed with
name>string
(see Name token).
The >f+c
field contains flags and the name length (count). You
read the count with name>string
, and the flags with
compile-only?
( nt – flag ) gforth-1.0 “compile-only?”
true if nt is marked as compile-only.
The >link
field contains a link to the previous word in the
same word list. You can read it with name>link
(see Name token).
The name, >f+c
and >link
fields are not present for
noname
words, but name>string
and name>link
work
nevertheless, producing 0 0 and 0, respectively.
The >cfa
field (aka code field) contains the code address used
for execute
ing the word; you can read it with
>code-address
and write it with code-address!
(see Threading Words).
The >namehm
field contains the address of the header methods
table, described below. You access it by performing or accessing
header methods (see Header methods).
The >body
(aka parameter) field contains data or threaded code
specific to the word type; its length depends on the word type. E.g.,
for a constant
it contains a cell with the value of the
constant. You can access it through >body
(see The gory details of CREATE..DOES>
), but this is only standard for words
you defined with create
.