home .. forth .. colorforth mail list archive ..

[ColorForth] immediate


Dear ColorForth list readers:

Jecel Assumpcao Jr wrote:
> My question is: why is this a good thing? Using color seems simpler and
> makes the code more readable. I can see that it makes it easier for the
> programmer to mess up, but surely that isn't a great worry in Forth?

I am not sure if you are asking why the use of Macro and Forth
wordlists is considered good compared to the traditional
implementation of an immediate bit in the dictionary header
and mixing the immediate words and non-immediate words
in the same wordlist or if you are asking why use color.

Chuck has used the macro/Forth wordlist approach since cmForth
because it speeds searches and simplies the internals of the
compiler.

The theory behind the color experiment includes a number of potential
benefits:

It yields a smaller, simpler, faster Forth compiler.  Departing
from the tradional Forth practice of just parsing forward looking
for space delimted words the tokens inform the compiler of what
is ahead and invoke the appropriate action without as much overhead
on each word.  This along with a lot of other things that Chuck is 
doing it makes his ColorForth very fast.  Other people are used to
seeing chip compiles taking hours and it happens in a keyclick in
OKAD II.

The code becomes more dense.  Chuck likes dense code where there is
less to look at to comprehend the meaning of a definition.  Chuck
likes short defintions.  Chuck's ColorForth also uses techniques
other than color change tokens to enforce short definitions.

If one looks at research in human perception and attention
there is a lot of evidence that we can only focus on so
much at once, and we perceive some different things with
different parts of the brain.  Of course it varies from
person to person, but the numbers for humans and gorillas
etc. have been studied.

One part of the brain maps a sequence of characters into a 
pattern known as a word, and matches that word as it were 
from a dictionary.  In normal source your brain must do 
this on every symbol to determine the meaning.  

A different part of the brain (and optic system) will recognize
colored sections in the source listing.  Moving some of the
requirement to recognize the content of the source to a different
part of the brain lets the part that does symantics to have to
focus on fewer words to get the meaning.  In theory this should
make the meaning of the code more obvious and let the programmer
focus on the remaining semantics, and Forth is a semantic language
with little syntactic information.  ColorForth removes some of
the remaining syntactic processing in Forth to reduce the word
count, make things simpler and fast, and let the programmer
focus on the remaining meaning more clearly.

Is all this a good thing?  Who knows.  It is an experiment.  It
is different and that means bad to many people who like to see
everyone follow long established traditions.

> I am implementating a CF for the Atmel ATmega103 and have run into two
> problems: the LCD is black and white :-) 

Of course "color" means "visually distinctive."  If you have B/W
you can still have a ColorForth if you can make the different
types of words visually distinctive.  You might use bold, italic,
smaller or larger fonts, different fonts, or even simply layout
cues.  For instance RED words could be the only words that are
left justified.  Just as many people enforce layout rules and
only left justify definitions of new words, : words etc. and
indent the body of their definitions to make the source
visually clear.

One could also use some of the internal techniques from
ColorForth without using the ColorForth interface idea
or any colors.  Some people may want to have the code
look traditional but have streamlined internals taken
from ColorForth.

Those who enforce layout rules on their source are doing something
related to the ideas behind ColorForth.  The idea is to make the
source more readable, more meaningful, more beautiful, more
"colorful."

> and this chip can't program
> its own Flash memory. I wanted to do a resident system rather than a
> cross development one...

Please keep us informed about your project.

Jeff Fox
------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.ultratechnology.com