version 1.35, 1999/05/21 20:35:37
|
version 1.36, 1999/05/22 20:03:54
|
Line 8
|
Line 8
|
@comment 4. search for TODO for other minor and major works required. |
@comment 4. search for TODO for other minor and major works required. |
@comment 5. [rats] change all @var to @i in Forth source so that info |
@comment 5. [rats] change all @var to @i in Forth source so that info |
@comment file looks decent. |
@comment file looks decent. |
|
@c Not an improvement IMO - anton |
|
@c and anyway, this should be taken up |
|
@c with Karl Berry (the texinfo guy) - anton |
@comment .. would be useful to have a word that identified all deferred words |
@comment .. would be useful to have a word that identified all deferred words |
@comment should semantics stuff in intro be moved to another section |
@comment should semantics stuff in intro be moved to another section |
|
|
Line 5129 execution token. You can produce the exe
|
Line 5132 execution token. You can produce the exe
|
|
|
@example |
@example |
: greet ( -- ) ." Hello" ; |
: greet ( -- ) ." Hello" ; |
: foo ( -- xt ) ['] greet ; \ ['] parses greet at compile-time |
: foo ( -- xt ) ['] greet execute ; \ ['] parses greet at compile-time |
: bar ( -- ) ' EXECUTE ; \ ' parses at run-time |
: bar ( -- ) ' execute ; \ ' parses at run-time |
|
|
\ the next four lines all do the same thing |
\ the next four lines all do the same thing |
foo EXECUTE |
foo |
|
bar greet |
greet |
greet |
' greet EXECUTE |
' greet EXECUTE |
boo greet |
|
@end example |
@end example |
|
|
An execution token occupies one cell. |
An execution token occupies one cell. |
Line 5166 At present, the @i{w} part of a compilat
|
Line 5169 At present, the @i{w} part of a compilat
|
and the @i{xt} part represents either @code{execute} or |
and the @i{xt} part represents either @code{execute} or |
@code{compile,}@footnote{Depending upon the compilation semantics of the |
@code{compile,}@footnote{Depending upon the compilation semantics of the |
word. If the word has default compilation semantics, the @i{xt} will |
word. If the word has default compilation semantics, the @i{xt} will |
represent @code{compile,}. If the word is @code{immediate}, the @i{xt} |
represent @code{compile,}. Otherwise (e.g., for immediate words), the |
will represent @code{execute}.}. However, don't rely on that knowledge, |
@i{xt} will represent @code{execute}.}. However, don't rely on that |
unless necessary; future versions of Gforth may introduce unusual |
knowledge, unless necessary; future versions of Gforth may introduce |
compilation tokens (e.g., a compilation token that represents the |
unusual compilation tokens (e.g., a compilation token that represents |
compilation semantics of a literal). |
the compilation semantics of a literal). |
|
|
You can compile the compilation semantics with @code{postpone,}. I.e., |
You can compile the compilation semantics with @code{postpone,}. I.e., |
@code{COMP' @i{word} postpone,} is equivalent to @code{postpone |
@code{COMP' @i{word} postpone,} is equivalent to @code{postpone |
Line 5203 doc-name>string
|
Line 5206 doc-name>string
|
@cindex word lists |
@cindex word lists |
@cindex header space |
@cindex header space |
|
|
@cindex wid |
A wordlist is a list of named words; you can add new words and look up |
All definitions other than those created by @code{:noname} have an entry |
words by name (and you can remove words in a restricted way with |
in the header space. The header space is fragmented into a number |
markers). Every named (and @code{reveal}ed) word is in one wordlist. |
of parts, called @dfn{word lists}. A word list is identified by a |
|
cell-sized word list identifier (@i{wid}) in much the same way as a |
@cindex search order stack |
file is identified by a file handle. The numerical value of the wid has |
The text interpreter searches the wordlists present in the search order |
no (portable) meaning, and might change from session to session. |
(a stack of wordlists), from the top to the bottom. Within each |
|
wordlist, the search starts conceptually at the newest word; i.e., if |
|
two words in a wordlist have the same name, the newer word is found. |
|
|
@cindex compilation word list |
@cindex compilation word list |
At any one time, a single word list is defined as the word list to which |
New words are added to the @dfn{compilation wordlist} (aka current |
all new definitions will be added -- this is called the @dfn{compilation |
wordlist). |
word list}. When Gforth is started, the compilation word list is the |
|
word list called @code{FORTH-WORDLIST}. |
|
|
|
@cindex search order stack |
@cindex wid |
Forth maintains a stack of word lists, representing the @dfn{search |
A word list is identified by a cell-sized word list identifier (@i{wid}) |
order}. When the header space is searched (for example, when |
in much the same way as a file is identified by a file handle. The |
attempting to find a word's execution token during compilation), only |
numerical value of the wid has no (portable) meaning, and might change |
those word lists that are currently in the search order are |
from session to session. |
searched. The most recently-defined word in the word list at the top of |
|
the word list stack is searched first, and the search proceeds until |
|
either the word is located or the oldest definition in the word list at |
|
the bottom of the stack is reached. Definitions of the word may exist in |
|
more than one word lists; the search order determines which version will |
|
be found. |
|
|
|
The ANS Forth ``Search order'' word set is intended to provide a set of |
The ANS Forth ``Search order'' word set is intended to provide a set of |
low-level tools that allow various different schemes to be |
low-level tools that allow various different schemes to be |
Line 5248 doc-get-order
|
Line 5245 doc-get-order
|
doc---thisone-set-order |
doc---thisone-set-order |
doc-wordlist |
doc-wordlist |
doc-table |
doc-table |
|
doc-push-order |
|
doc-previous |
doc-also |
doc-also |
doc---thisone-forth |
doc---thisone-forth |
doc-only |
doc-only |
doc---thisone-order |
doc---thisone-order |
doc-previous |
|
|
|
doc-find |
doc-find |
doc-search-wordlist |
doc-search-wordlist |