Jump to content
IGNORED

[TurboForth] Tip: MARKER


Recommended Posts

Crossposted from : http://tech.groups.yahoo.com/group/turboforth/message/380

 

Seasoned Forth veterans will know of MARKER. Those of you that don't will find it very handy.

 

 

MARKER works a little bit like FORGET, but you can use MARKER in blocks to mark a section of code that is to be removed.

 

 

Firstly, the definition of MARKER:

 

 

: MARKER LATEST @ CREATE , DOES> @ LATEST ! ;

 

 

Now, say you are working on some code, and have 75% of your definitions working and tested:

 

 

: def1 ... ... ... ... ;

: def2 ... ... ... ... ;

: def3 ... ... ... ... ;

: def4 ... ... ... ... ;

 

 

You now want to start work on def5 def6 and def7. This will mean repeatedly removing them from memory with FORGET, or using COLD and reloading the entire application from the beginning. This can get tedious with a large application, especially if you are working from floppy disk.

 

 

 

With MARKER, you can create a marker at the point at which you want to erase the dictionary entries, like this:

 

 

: def1 ... ... ... ... ;

: def2 ... ... ... ... ;

: def3 ... ... ... ... ;

: def4 ... ... ... ... ;

MARKER WORK-POINT

: def5 ... ... ... ... ;

: def6 ... ... ... ... ;

: def7 ... ... ... ... ;

 

 

This creates a word called WORK-POINT that, when executed, erases all the words in the dictionary immediately following it. So, if you did this:

 

 

: def1 ... ... ... ... ;

: def2 ... ... ... ... ;

: def3 ... ... ... ... ;

: def4 ... ... ... ... ;

MARKER WORK-POINT

: def5 ... ... ... ... ;

: def6 ... ... ... ... ;

: def7 ... ... ... ... ;

WORK-POINT

 

Then def5, def6 and def7 will be removed from the dictionary, but def1, def2, def3, and def4 will still remain. You can then repeatedly re-define your words, leaving the words that you have already written and de-bugged in memory.

 

Neat.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...