Krishna Myneni
2012-01-16 12:36:26 UTC
Others must have brought up this question previously, but I'm
wondering why there are no standard words in Forth for traversing a
wordlist and obtaining basic information about each node? While
standard Forth provides a great many features for extensibility of the
language (with CREATE ... DOES> being the classic example), standard
Forth seems to be lacking the basic capability of traversing the
wordlist as a part of the language. Such a capability is needed to
provide some kinds of advanced programming tools. For example, I may
want to determine all instances of word name overlaps in all of the
wordlists in the current search order. AFAIK, there is no standard way
to do that presently.
On first thought, the minimum set of wordlist traversal words needed
are,
a) Set the current node to the head or the tail of the wordlist --
only one is sufficient if we restrict ourselves to a single direction
for the traversal.
b) Advance to the next node or backup to the previous node (again,
only one will suffice).
c) Obtain the xt of the current node
d) Obtain the name of the current node (i.e. name of the word)
Note that the term node is only used descriptively -- there does not
need to be an actual linked list in the underlying system
implementation of wordlists. The above set of functions should be
independent of the implementation details, but maybe I'm overlooking
something. Perhaps embedded systems do not retain word names in their
run-time environment (but, then, emdedded systems do not have to
support this set of words).
Some Forth systems may support the above functions partially or fully.
What is the existing practice in Forth systems?
Krishna
wondering why there are no standard words in Forth for traversing a
wordlist and obtaining basic information about each node? While
standard Forth provides a great many features for extensibility of the
language (with CREATE ... DOES> being the classic example), standard
Forth seems to be lacking the basic capability of traversing the
wordlist as a part of the language. Such a capability is needed to
provide some kinds of advanced programming tools. For example, I may
want to determine all instances of word name overlaps in all of the
wordlists in the current search order. AFAIK, there is no standard way
to do that presently.
On first thought, the minimum set of wordlist traversal words needed
are,
a) Set the current node to the head or the tail of the wordlist --
only one is sufficient if we restrict ourselves to a single direction
for the traversal.
b) Advance to the next node or backup to the previous node (again,
only one will suffice).
c) Obtain the xt of the current node
d) Obtain the name of the current node (i.e. name of the word)
Note that the term node is only used descriptively -- there does not
need to be an actual linked list in the underlying system
implementation of wordlists. The above set of functions should be
independent of the implementation details, but maybe I'm overlooking
something. Perhaps embedded systems do not retain word names in their
run-time environment (but, then, emdedded systems do not have to
support this set of words).
Some Forth systems may support the above functions partially or fully.
What is the existing practice in Forth systems?
Krishna