ColorForth

Chuck Moore’s ColorForth (formerly available at http://www.colorforth.com, now some info at http://www.inventio.co.uk/cf2019_colorForth.pdf) is a very interesting system. While I admire it both as a novelty and as an effective system in some hands and for some projects, I do not see how I can adopt it entirely at this time. Below are some specific comments, but I reserve the right to change my mind.


Use of color to “tag” words in the source

I have no objection to this. I even began writing an Emacs mode to try this out. It more or less works, but would need some polishing. See the link to it from my main Forth page (../forth.html).

However, I am still using symbols (rather than color) to “tag” words in Riscy Pygness. Specifically,

  • A quote mark followed by a space tags the following text up to an ending quote mark as a string,
  • A colon followed by a space tags the following word as a label,
  • Literal numbers
    • A dollar sign at the beginning of a number tags it as a hexadecimal number (e.g. $03F8),
    • An ampersand at the beginning of a number tags it as a literal to be looked up on the host (rather than the target) (e.g. &PINSEL0),
    • A single quote mark followed by a letter tags it as as the ASCII value of the character (e.g. 'A is the number 65),
    • A word that is a valid decimal number but is not in the table of label names does not need a tag.
  • The word VARIABLE tags the following word as a variable.

So, other than the verbosity of using symbols rather than color for tags, my system seems fairly compatible both with ColorForth and with classic Forth.

Just two tasks

ColorForth appears to have exactly two tasks, a foreground task and a background task.

Riscy Pygness similarly has a fixed number of tasks (three in the current version, although this is adjustable).

Some unusual simplifications

In ColorForth, OR means exclusive OR and there is no inclusive OR

I am not able to wrap my mind around this and so retain both the usual OR and XOR.

Multiple entry points and exit points and optimised tail recursion

I embrace these wholeheartedly.

  • Riscy Pygness allows multiple labels per word. (This makes Forth word names virtually identical to assembler labels.)
  • It allows multiple exits from a word (using ; to represent the exit).
  • When encountering a semicolon, if possible, it changes the preceding subword from a call to a jump and omits compiling an actual exit. In the source code of the compiler, you will see the definition of CUT (which I believe was written as // in ColorForth and/or some of Chuck’s other Forths), which is used to mark special cases where the use of a semicolon must not cause the preceding subword to be changed to a jump and must result in the compiling of an actual exit, e.g. after a THEN.