Previous: , Up: Tokens for Words   [Contents][Index]


5.11.3 Name token

Gforth represents named words by the name token, (nt). Name token is an abstract data type that occurs as argument or result of the words below.

The closest thing to the nt in older Forth systems is the name field address (NFA), but there are significant differences: in older Forth systems each word had a unique NFA, LFA, CFA and PFA (in this order, or LFA, NFA, CFA, PFA) and there were words for getting from one to the next. In contrast, in Gforth 0…n nts correspond to one xt; there is a link field in the structure identified by the name token, but searching usually uses a hash table external to these structures; the name in Gforth has a cell-wide count-and-flags field, and the nt is not implemented as the address of that count field.

find-name ( c-addr u – nt | 0  ) gforth-0.4 “find-name”

Find the name c-addr u in the current search order. Return its nt, if found, otherwise 0.

find-name-in ( c-addr u wid – nt | 0  ) unknown “find-name-in”

search the word list identified by wid for the definition named by the string at c-addr u. Return its nt, if found, otherwise 0.

latest ( – nt  ) gforth-0.6 “latest”

nt is the name token of the last word defined; it is 0 if the last word has no name.

>name ( xt – nt|0  ) gforth-0.4 “to-name”

The primary name token nt of the word represented by xt. Returns 0 if xt is not an xt (using a heuristic check that has a small chance of misidentifying a non-xt as xt), or if the primary nt is of an unnamed word. As of Gforth 1.0, every xt has a primary nt, but other named words may have the same interpretation sematics xt.

name>interpret ( nt – xt|0  ) unknown “name>interpret”

xt represents the interpretation semantics nt; returns 0 if nt has no interpretation semantics

name>compile ( nt – w xt  ) unknown “name>compile”

w xt is the compilation token for the word nt.

name>int ( nt – xt  ) gforth-0.4 “name-to-int”

xt represents the interpretation semantics of the word nt.

name?int ( nt – xt  ) gforth-obsolete “name-question-int”

Like name>int, but warns when encountering a word marked compile-only

name>comp ( nt – w xt  ) gforth-0.4 “name-to-comp”

w xt is the compilation token for the word nt.

name>string ( nt – addr u  ) gforth-0.4 “name-to-string”

addr count is the name of the word represented by nt.

id. ( nt –  ) gforth-0.6 “i-d-dot”

Print the name of the word represented by nt.

.name ( nt –  ) gforth-obsolete “dot-name”

Gforth <=0.5.0 name for id..

.id ( nt –  ) F83 “dot-i-d”

F83 name for id..


Previous: Compilation token, Up: Tokens for Words   [Contents][Index]