Saturday, 20 March 2010

In Threaded Interpretive Languages, Loeliger explores the design and implementation of TILs in an individual quirky style. Programs in a threaded language typically compiles to a list of subroutine calls or addresses. Loeliger focuses on Forth-like threaded languages and provides examples in Z80 assembly language.

After the standard introductory chapter the book gets straight down to the implementation details, first dealing with the design of the dictionary format, inner and outer interpreters. This is followed by example code for the interpreters and assembly language definitions for 170 of the most common subroutines.

Later chapters investigate some common extensions to TILs including virtual memory and floating point numbers. A section is devoted to assemblers and includes code for a structured Z80 assembler.

Threaded Interpretive Languages contains the most in-depth examination of Forth internals I've seen. However the age of the books shows in the dialect of Forth used and the systems described. Despite this, I'd still recommend Threaded Interpretive Languages to anyone planning to implement a minimal Forth.

It was a few days since I last checked your blog! Thanks for the links. I have already printed Jones Forth (although it is quite "heavy"), will take a look at the other two, then. But it was a month since I last wrote a line of Forth! Ajj! My raytracer is not going well :/

That last link of John's should probably have been "eForth x86 by Bill Muench".

I actually have a copy of Loeliger's book, which I bought new many years ago to help me implement a project that management insisted be done in IBM 360 assembler and/or Cobol even though it needed something higher level. As a work around, I researched high level things I could set up in those, and found Forth; then I basically wrote it in Forth on top of IBM 360 assembler, with a separate Cobol module for the I/O, using assembler macros rather than a text interpreter and Forth source so that technically I stayed within the permitted environment (it would have gone quicker if I had been allowed the more interactive Forth environment, though - I wouldn't have needed an editor etc. but just a text interpreter, since I could have piped source into it from a PC file). It was a triumph of misguided ingenuity, since the whole project was clearly worthless from the beginning anyway (it was meant to deskill the use of another package, but installing it in an IBM mainframe environment meant that the users would need to learn something just as awkward to get it in the first place).

There are two scanned versions preserved: http://sinclairql.speccy.org/archivo/docs/books/Threaded_interpretive_languages.pdf and http://mirrors.acm.jhu.edu/textfiles/bitsaved/Books/Loeliger_threadedInterpLang.pdf.