Diff for /gforth/doc/gforth.ds between versions 1.115 and 1.116

version 1.115, 2003/03/11 21:18:32 version 1.116, 2003/03/22 10:04:08
Line 5958  words: Line 5958  words:
   
 doc-noname  doc-noname
 @cindex execution token of last defined word  @cindex execution token of last defined word
 doc-lastxt  doc-latestxt
   
 @noindent  @noindent
 The previous example can be rewritten using @code{noname} and  The previous example can be rewritten using @code{noname} and
 @code{lastxt}:  @code{latestxt}:
   
 @example  @example
 Defer deferred  Defer deferred
 noname : ( ... -- ... )  noname : ( ... -- ... )
   ... ;    ... ;
 lastxt IS deferred  latestxt IS deferred
 @end example  @end example
   
 @noindent  @noindent
 @code{noname} works with any defining word, not just @code{:}.  @code{noname} works with any defining word, not just @code{:}.
   
 @code{lastxt} also works when the last word was not defined as  @code{latestxt} also works when the last word was not defined as
 @code{noname}.  It does not work for combined words, though.  It also has  @code{noname}.  It does not work for combined words, though.  It also has
 the useful property that is is valid as soon as the header for a  the useful property that is is valid as soon as the header for a
 definition has been built. Thus:  definition has been built. Thus:
   
 @example  @example
 lastxt . : foo [ lastxt . ] ; ' foo .  latestxt . : foo [ latestxt . ] ; ' foo .
 @end example  @end example
   
 @noindent  @noindent
Line 6038  make a call to @code{stats}. You can def Line 6038  make a call to @code{stats}. You can def
 : stats ( xt -- ) DUP ." (Gathering statistics for " . ." )"  : stats ( xt -- ) DUP ." (Gathering statistics for " . ." )"
   ... ;  \ other code    ... ;  \ other code
   
 : my: : lastxt postpone literal ['] stats compile, ;  : my: : latestxt postpone literal ['] stats compile, ;
   
 my: foo + - ;  my: foo + - ;
 @end example  @end example
Line 6050  When @code{foo} is defined using @code{m Line 6050  When @code{foo} is defined using @code{m
 @code{my:} is executed.  @code{my:} is executed.
 @item  @item
 The @code{:} within the definition (the one between @code{my:} and  The @code{:} within the definition (the one between @code{my:} and
 @code{lastxt}) is executed, and does just what it always does; it parses  @code{latestxt}) is executed, and does just what it always does; it parses
 the input stream for a name, builds a dictionary header for the name  the input stream for a name, builds a dictionary header for the name
 @code{foo} and switches @code{state} from interpret to compile.  @code{foo} and switches @code{state} from interpret to compile.
 @item  @item
 The word @code{lastxt} is executed. It puts the @i{xt} for the word that is  The word @code{latestxt} is executed. It puts the @i{xt} for the word that is
 being defined -- @code{foo} -- onto the stack.  being defined -- @code{foo} -- onto the stack.
 @item  @item
 The code that was produced by @code{postpone literal} is executed; this  The code that was produced by @code{postpone literal} is executed; this
Line 6394  An alternative would have been to write Line 6394  An alternative would have been to write
 : @var{inst-format} ( entry-num "name" -- )  : @var{inst-format} ( entry-num "name" -- )
   here name string, ( entry-num c-addr ) \ parse and save "name"    here name string, ( entry-num c-addr ) \ parse and save "name"
   noname create , ( entry-num )    noname create , ( entry-num )
   lastxt swap cells @var{table} + !    latestxt swap cells @var{table} + !
 does> ( addr w -- )  does> ( addr w -- )
   \ disassemble instruction w at addr    \ disassemble instruction w at addr
   @@ >r     @@ >r 
Line 6429  does> ( u "inst" -- ) Line 6429  does> ( u "inst" -- )
     \ and enters it as u-th entry into table-xt      \ and enters it as u-th entry into table-xt
     2@@ swap here name string, ( u table-xt disasm-xt c-addr ) \ remember string      2@@ swap here name string, ( u table-xt disasm-xt c-addr ) \ remember string
     noname create 2,      \ define anonymous word      noname create 2,      \ define anonymous word
     execute lastxt swap ! \ enter xt of defined word into table-xt      execute latestxt swap ! \ enter xt of defined word into table-xt
 does> ( addr w -- )  does> ( addr w -- )
     \ disassemble instruction w at addr      \ disassemble instruction w at addr
     2@@ >r ( addr w disasm-xt R: c-addr )      2@@ >r ( addr w disasm-xt R: c-addr )
Line 6897  semantics).  You might get what you want Line 6897  semantics).  You might get what you want
 DROP} or @code{[COMP'] @i{word} DROP} (for details @pxref{Compilation  DROP} or @code{[COMP'] @i{word} DROP} (for details @pxref{Compilation
 token}).  token}).
   
 Another way to get an XT is @code{:noname} or @code{lastxt}  Another way to get an XT is @code{:noname} or @code{latestxt}
 (@pxref{Anonymous Definitions}).  For anonymous words this gives an xt  (@pxref{Anonymous Definitions}).  For anonymous words this gives an xt
 for the only behaviour the word has (the execution semantics).  For  for the only behaviour the word has (the execution semantics).  For
 named words, @code{lastxt} produces an XT for the same behaviour it  named words, @code{latestxt} produces an XT for the same behaviour it
 would produce if the word was defined anonymously.  would produce if the word was defined anonymously.
   
 @example  @example
Line 6954  doc-postpone, Line 6954  doc-postpone,
 @subsection Name token  @subsection Name token
   
 @cindex name token  @cindex name token
   Gforth represents named words by the @dfn{name token}, (@i{nt}).  Name
   token is an abstract data type that occurs as argument or result of the
   words below.
   
   @c !! put this elswhere?
 @cindex name field address  @cindex name field address
 @cindex NFA  @cindex NFA
 Gforth represents named words by the @dfn{name token}, (@i{nt}). In  The closest thing to the nt in older Forth systems is the name field
 Gforth, the abstract data type @emph{name token} is implemented as a  address (NFA), but there are significant differences: in older Forth
 name field address (NFA).  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@dots{}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.
   
 doc-find-name  doc-find-name
   doc-latest
   doc->name
 doc-name>int  doc-name>int
 doc-name?int  doc-name?int
 doc-name>comp  doc-name>comp
Line 11604  is given in a comment before the instruc Line 11617  is given in a comment before the instruc
 because the recognition of the end of the code is unreliable.  You can  because the recognition of the end of the code is unreliable.  You can
 use @code{disasm} if it did not display enough.  It may display more, if  use @code{disasm} if it did not display enough.  It may display more, if
 the code word is not immediately followed by a named word.  If you have  the code word is not immediately followed by a named word.  If you have
 something else there, you can follow the word with @code{align last @ ,}  something else there, you can follow the word with @code{align latest ,}
 to ensure that the end is recognized.  to ensure that the end is recognized.
   
 @node 386 Assembler, Alpha Assembler, Common Disassembler, Assembler and Code Words  @node 386 Assembler, Alpha Assembler, Common Disassembler, Assembler and Code Words
Line 13395  Not implemented (yet). Line 13408  Not implemented (yet).
 The word is entered into the word list that was the compilation word list  The word is entered into the word list that was the compilation word list
 at the start of the definition. Any changes to the name field (e.g.,  at the start of the definition. Any changes to the name field (e.g.,
 @code{immediate}) or the code field (e.g., when executing @code{DOES>})  @code{immediate}) or the code field (e.g., when executing @code{DOES>})
 are applied to the latest defined word (as reported by @code{last} or  are applied to the latest defined word (as reported by @code{latest} or
 @code{lastxt}), if possible, irrespective of the compilation word list.  @code{latestxt}), if possible, irrespective of the compilation word list.
   
 @item search order empty (@code{previous}):  @item search order empty (@code{previous}):
 @cindex @code{previous}, search order empty  @cindex @code{previous}, search order empty

Removed from v.1.115  
changed lines
  Added in v.1.116


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>