6.26.6 Forgetting words

Forth allows you to forget words (and everything that was alloted in the dictonary after them) in a LIFO manner.

marker ( "<spaces> name" –  ) core-ext “marker”

Create a definition, name (called a mark) whose execution semantics are to remove itself and everything defined after it.

The most common use of this feature is during progam development: when you change a source file, forget all the words it defined and load it again (since you also forget everything defined after the source file was loaded, you have to reload that, too). Note that effects like storing to variables and destroyed system words are not undone when you forget words. With a system like Gforth, that is fast enough at starting up and compiling, I find it more convenient to exit and restart Gforth, as this gives me a clean slate.

Here’s an example of using marker at the start of a source file that you are debugging; it ensures that you only ever have one copy of the file’s definitions compiled at any time:

[IFDEF] my-code

marker my-code

\ .. definitions start here
\ .
\ .
\ end