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

Re: Re(2): [colorforth] merging dictionaries


Ok,

As you may know colorForth has a function table to associate each color
with a meaning. A red word is a definition with two possible meanings. The
word 'forth' selects the meaning which creates and entry in forth
dictionary and the word 'macro' selects the meaning which creates an
entry in the macro dictionary.

An entry is simply a (name, address) pair. The name, as is probably well
known, is a string of huffman coded characters packed into the upper 28
bits of a 32-bit word. Why 28 bits? Because as we know each preparsed word in
colorForth source code contains a 4 bit tag which determines the word's
meaning. The address is simply the location the dictionary pointer points
to when the entry is created.

Entries are stored in a parallel array, two sequences of 32-bit words of
equal length. In colorForth there are two parallel arrays, one for macro
entries, and one for forth entries. Two values keep track of the number of
entries in each dictionary, 'macros' and 'forths' respectively. These two
values and dictionary pointer are saved with 'mark' word, and restored
with the word 'empt'.

Dictionaries are searched from the last entry to the first using a simple
comparision of 32-bit values, equality implying the name is found. When a
green word is encountered in colorForth source, the name is searched first
in the macro dictionary, secondly in the forth dictionary. If the name is
found in the the macro dictionary the corresponding address is jumped to.
If the word is not found in the macro dictionary, the forth dictionary is
searched and if the name is found a pentium call to the corresponding
address is compiled to the dictionary space. If name is not found in
either dictionary the familer 'abort' word is jumped to.

Given the semantics of colorForth, other implementations of the dictionary
are possible. I'm working a port of colorForth to the ARM architechture,
so I am interested in other implementations which might simplify
colorForth. Merging two dictionaries into one is an attempt to simplify.
However macro entries now need to be distinguished. What I have done is
added one to the name when creating a macro entry, and one to the name
when searching for a macro entry. This change does in fact result in less
code as I have already reported. I'm interested in exploring Chuck's
aproach as well as this does not seem to have the speed disadvantage of
my approach and might be more intuitive for defining words, forth names
displacing macros of the same name.

Mark



On Tue, 17 Jun 2003, Peter Appelman wrote:

> On Mon, Jun 16, 2003 at 09:22:50PM -0400, Mark Slicker wrote:
> > Yes, this dicussion is turning a strange direction. I explained the method
> > no less than three times and I get pinned with all kinds of innuendo. I'm
> > not sure Peter or Arthur understand how the colorForth dictionaries are
> > implemented. I'd be happy to explain, if an explanation is desired.
>
> Please explain, perhaps I'm wrong in my assumptions.
>
> Peter.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
> For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
> Main web page - http://www.colorforth.com
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com