home .. forth .. misc mail list archive ..

aha ideas


Hi Jeff,

I thought that you might be interested in a couple of
ideas which I intend to try out when I get a chance.  I
posted a slightly different version to the forum at
Sean's Flux home page.  The first is relatively simple
and is just to use different colors (and tokens) for
'variable @' and 'variable !', so you just see the same
name in different colors to represent @ and !.   I got
the idea from Sean's Flux where he creates variables by
just defining a name and embeding a 0 (or initialization
value) into the compiled code space.  The address of the
variable is still available as the CFA of the word.

The other idea is to move all wordlist operations into
the editor.  I did notice that you said in 'Thoughtful
Programing' that Chuck has abandoned wordlists in his
Color Forth, but to me the whole point of the high speed
compilation of 'aha' is to be able to have all of the
source for the system and all applications available at
once and for that, I think you would still need to use
wordlists.  My idea is to embed the wordlist commands
into comment records (skipped by the compiler) which
would have a token field indicating which command the
record represents.  The wordlist commands which I
thought would be useful to implement are:

F7 create and set 'current' vocabulary
<shift>F7 create and set 'context' vocabulary

F8 save previous and set 'current' vocabulary
<shift>F8 save previous and set 'context' vocabulary

F9 restore previous 'current' vocabulary
<shift>F9 restore previous 'context' vocabulary


Notes:
-The editor must keep track of 'current' and 'context'
as it moves through the tokenized source.

-If <shift>F8's occur immediately after a new 'context'
vocabulary has been created (<shift>F7), they are
considered to be defining a series of vocabularies to be
searched under one vocabulary name.  i.e.:

<shift><F7>fullmath<shift><F8>extmath<shift><F8>math

will create a new vocabulary called 'fullmath' which
will first search 'extmath' and then 'math'.  It is an
error to set a name which is a series of vocabularies to
'current'.

-Internally, vocabularies are a pointer to the start of
a linked list, followed by a zero in the case of a basic
vocabulary or a series of pointers to other vocabularies
(or series' of vocabularies) followed by a zero.

-F8 could save only one vocabulary pointer or it could
be a stack.  I think that a single pointer would be
easier to deal with, but a stack would be more
'forthish'.

-Pressing <shift>F8 inserts the name of the previous
'context' vocabulary.

-If a vocabulary command is inserted into the middle of
the tokenized source, the source must be re-tokenized
from that point to the next overriding vocabulary
command or the end of the source.

Cheers,
Mark