Go to the first, previous, next, last section, table of contents.


Supplying names for the defined words

By default, defining words take the names for the defined words from the input stream. Sometimes you want to supply the name from a string. You can do this with

nextname       c-addr u --         gforth       ``nextname''

E.g.,

s" foo" nextname create

is equivalent to

create foo

Sometimes you want to define a word without a name. You can do this with

noname       --         gforth       ``noname''

To make any use of the newly defined word, you need its execution token. You can get it with

lastxt       -- xt         gforth       ``lastxt''

E.g., you can initialize a deferred word with an anonymous colon definition:

Defer deferred
noname : ( ... -- ... )
  ... ;
lastxt IS deferred

lastxt also works when the last word was not defined as noname.

The standard has also recognized the need for anonymous words and provides

:noname       -- xt colon-sys         core-ext       ``colon-no-name''

This leaves the execution token for the word on the stack after the closing ;. You can rewrite the last example with :noname:

Defer deferred
:noname ( ... -- ... )
  ... ;
IS deferred


Go to the first, previous, next, last section, table of contents.