[ColorForth] immediate
- Subject: [ColorForth] immediate
- From: "Dirk Heise" <dheise@xxxxxxxxxxx>
- Date: Wed, 23 May 2001 10:02:04 +0200
> Von: Jecel Assumpcao Jr <jecel@xxxxxxxxxxxxx>
> An: ColorForth List Member <ColorForth@xxxxxxxxxxxxxxxxxx>
> Betreff: [ColorForth] immediate
> Datum: Dienstag, 22. Mai 2001 23:25
[...]
> I am implementating a CF for the Atmel ATmega103 and have run into two
> problems: the LCD is black and white :-) and this chip can't program
> its own Flash memory. I wanted to do a resident system rather than a
> cross development one...
>
> -- Jecel
I will run into the B/W problem with an old notebook i want to
re-use. My idea (that i explained in this gorup a few days or weeks
ago) was to automatically create two versions of each
newly defined word, like this:
: 1+ 1 , +, ;
: 1+, ' 1+ , compile, ;
where: "," transfers a number literal from compile time to
runtime (compiles a literal).
"1+" is the "immediate" version of the word
"1+," is the word that compiles the "1+".
So i use the "," postfix everywhere to make the distinction.
I have defined ":" in such a way that, when it encounters the
token "1+", it will first automatically create the "1+,"
word in the dictionary, and then the word header for "1+".
I hope that this convention will also allow to automatically
switch to a colorful display, where an editor could use the
"," as a hint to use a different color.
BTW, i made progress, the core, written in C, is complete
on paper. During the
writing process, i discovered that i never had to nest "if"s
or use an "else". In fact, *all* uses of if...then clauses
took a form like:
if ... ; then
or
if ... ;; then
( ";" exits the word, ";;" does tail recursion)
So, i decided to define a very simple "if" that can't be nested,
and give ";" and ";;" the semantics that they automatically close
an "if". (perform the action of a "then")
Imagine a word that shall return "TRUE" when it's input is
"0" or "1". Classically:
: test01 dup 1 = if exit then 0= ;
In my Forth, this will become:
: test01 dup, 1 , =, if ; 0=, ;
If somebody needs "else" or a nestable "if", he can easily
overload my definition, or create an "iff" as an alternative...
Dirk
------------------------
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