Forth and threading (was: strangest systems I've sent email from)
Jecel Assumpcao Jr.
jecel at merlintec.com
Fri Apr 29 15:57:51 CDT 2016
> I liked Forth when it was still threaded. You got the DOES> feature.
> Do you still have that with the FORTH chips?
All Forth implementations are threaded, but there are several kinds:
direct, indirect, token and subroutine. Initially indirect threading was
the most popular implementation choice but all Forth chips I am familiar
with use subroutine threading instead.
Subroutine threading has the highest performance, but it does take up
more space (each word uses a CALL opcode as well as the word's address)
and it kills CREATE DOES>, which is what you were asking about. There
are two solutions to this problem: in Color Forth you can type a word in
either green or yellow depending on whether you want its action to
happen at runtime or at compile time while in Machine Forth you can
define a word in either the normal vocabulary or the macro vocabulary to
get a similar effect.
The advantage of compile time words (which are different from playing
with the COMPILE flag in threaded Forths) is that you can inline the
code that would normally be in the DOES> portion of the word, which
saves you a call and a return. For a normal processor that might take up
more space, but for Forth chips this will almost always be a single
instruction which is much smaller than a call so you actually save
More information about the cctalk