Commodore User


The Complete Forth

Author: Richard Hunt
Publisher: Sigma Technical Press
Machine: Commodore Vic 20

 
Published in Commodore User #6

The Complete Forth

Any subject, no matter how esoteric will produce a standard text book. Forth is no exception. And the book that most people will consider as the book on Forth is Leo Brodie's Starting Forth; undoubtedly it is a valuable contribution to a general understanding of the language.

An alternative must be Alan Winfield's The Complete Forth (published by Sigma Technical Press at £6.95). It is cheaper, slimmer and British (the author being a lecturer in the Department of Electronic Engineering at Hull University).

Forth is essentially a portable language. In other words, source code written in Forth will compile and run on any computer system that supports Forth. At least, that's the theory: obviously any code in any language that makes use of the operating system or the special characteristics of a given computer will not be portable without some effort.

With Forth, though, it doesn't matter so much because if the programmer has knowledge of the purpose of the code he or she is able to define a Forth word that serves that purpose. This is the seence of extensibility and is what can make Forth a specialist's language. I like to think of it sometimes as a DIY language!

Be that as it may, a Forth implementation starts out with certain well-defined characteristics. Other than extensibility, these are use of the stack associated with Reverse Polish Notation (RPN): and a dictionary of 150 to 200 words which from the elementary building blocks of higher-level programs (known in Forth as 'words'). Understanding of these chracteristics is the stepping-stone to thinking and writing lucid Forth.

Coming Forth

Alan Winfield's book is subtitled "a new way to program microcomputers" and anyone new to Forth is recommended to take this as a literal statement. Most newcomers to Forth will arrive by way of another high-level language, probably Basic. Forth requires you to have only some idea of the function of a computer and not how that function is realised: put aside Basic statements and step into a looking-glass world where normalcy seems topsy-turvy (or at least backwards-looking) - this peculiar effect is a result of RPN and the stack.

Actually using a stack for all intermediate numeric results demands RPN. Also it is faster in operation: the familiar algebraic ordering system requires interpretation as well. The content of The Complete Forth is designed to introduce the beginner in easy stages to RPN and stack manipulation, leading early to examples of Forth words.

Naturally these are stack manipulating words that enhance Forth's arithmetical capability. Indeed I became very much bogged down in Chapter 1 trying to define some stack manipulating words like ((pick) and (roll)) which were not implemented on my system.

Gradually more complex ideas are examined and a Forth system and dictionary described. From word definition to Forth structures (conditionals and loops), examples accompany description. Reliance is made on Forth being an interactive language. You don't need to, but it can help if you sit down and enter the words and problems into your machine.

It is distinctly possible that the maker's handbook is less than explicit, and expert advice and can be needed. Winfield comes to the rescue with the chapter on Editing, Saving and Loading. A Forth editor is perhaps the most non-standard part of the system. Both Forth implementations I have used on my Vic have different editors: one makes use of natural features (if that is the term) built into the Vic (and other CBM machines) plus some clever use of RAM in lieu of disk.

The other follows more nearly recognisable Forth standards, and I discovered it was fully described in this chapter. Unfortunately as I have have intimated in my earlier review of that cartridge it did not make that particular editor any easier to use!

Richard Hunt