[comp.lang.forth] Compile-a-line model & state-smart words

tsaari@tukki.jyu.fi (Antero Taivalsaari) (01/09/90)

In article <9001070107.AA03495@jade.berkeley.edu> DAVID@PENNDRLS.BITNET 
(David Murray) writes:

>I had been thinking about the compile-a-line approach before the
>topic came up here, and it seems to me that the second biggest
>advantage of the approach is that it eliminates the need for
>state-smart words.  In fact, from a system design standpoint that
>may be the bigger of the advantages (interactive control structures
>being the other under discussion).

This is not true. Actually, in a true compile-a-line Forth 
state-smart and immediate words are even more important (and 
frequently used) than in traditional Forths. Think about the word 
'WORD', for example. To make it able to read the following input 
stream during compilation (outside of a colon definition) it must 
be immediate. However, when used inside a colon definition, WORD 
is not supposed to read anything until the compiled code is actually 
run. So, the definition of WORD becomes something like this:

: (word)  ... normal definition of 'WORD' ... ;
: word  state @ IF compile (word) ELSE (word) THEN ; immediate

There are some other words with equivalent problem, ' (tick) 
and ." (dot-quote), to mention. In general, all the words expecting 
stream input in a compile-a-line Forth must be made immediate (not 
necessarily state-smart) to be able to work outside of a colon definition
(If there are other solutions, I am interested to hear about them).

Personally I don't consider state-smart and/or immediate words 
as a problem, although the most people in the Forth community 
have been trying to avoid them for the last ten years. Actually, 
it is exactly these features which really distinguish Forth from 
(other) third generation languages, turning it into the only 
"extensive interactive compiler" -language.

Antero Taivalsaari
University of Jyvaskyla
FINLAND
tsaari@jyu.fi