StrongForth.f Homepage

StrongForth.f 1.2
Download
ANS Compliance
Version History

StrongForth is a programming language that is very close to ANS Forth. One of the biggest differences is that it includes strong static type-checking. ANS Forth itself is often called typeless or untyped, which means that neither interpreter nor compiler do any type-checking when applying a function (a word) to one or more operands. It is completely up to the programmer to chose the correct functions. In StrongForth, the interpreter and the compiler check if a function matches the operands on the stack. This allows finding type mismatches and unbalanced loops and conditional branches already at compile time. Additionally, it is possible to overload words by using the same name for different functions, as long as each word expects a different set of parameters on the stack.

The majority of Forth users might believe that strong static typing is not Forth-like. Nevertheless, the implementation of StrongForth proves that Forth can incorporate static type-checking without increasing the complexity of the language.

StrongForth.f 1.2

StrongForth.f is an implementation of StrongForth in ANS Forth. I. e., it is supposed to run as an application on every ANS Forth system, taking over properties like the cell size from its host. Although StrongForth.f has its own interpreter loop and its own dictionary, it takes full advantage of all optimizations that are incorporated in the host system's compiler. StrongForth.f has been successfully validated on GForth, SwiftForth™ and CHForth.

Everyone interested in Forth with strong static type-checking is invited to download a free copy of StrongForth.f 1.2. StrongForth.f is distributed under the GNU General Public license (see copying.txt).

Download StrongForth.f 1.2

To install StrongForth.f, simply unpack the ZIP file into a new directory.

The ZIP file contains

To run StrongForth.f as an application on your ANS Forth system, include the file strong.f and then enter STRONG to start StrongForth's interpreter loop. After the StrongForth.f command line prompt appears, include the core library:

S" <dir>\strong.f" INCLUDED  ok
STRONG  OK
" corelib.sf" INCLUDE  OK

Note that StrongForth uses INCLUDE to include a file, whereas the ANS Forth host uses INCLUDED. You might see a lot of warnings about redefinitions of words as a response to both INCLUDE's. These warnings can safely be ignored, because defining words that have the same name as already existing words is not unusual in StrongForth. In fact, if your host system allows disabling these warnings, you should do so. Your host system has to provide the following ANS Forth word sets in order to successfully include strong.f:

After the core library has been included, StrongForth.f is up and running. You may then include additional word sets and other StrongForth source files like the OOP package. If you are not yet familiar with StrongForth, it is recommended that you start working through the introduction intro.htm. Note that standard words are recognized in upper case only, because StrongForth.f is case sensitive by default. You can turn to case insensitivity by changing the value of the constant CASE-INSENSITIVE in the source file strong.f from FALSE to TRUE before including this file. Integer literals have data type UNSIGNED by default, and data type SIGNED if preceded by a sign character (- or +). Literals with a trailing decimal point are double-cell numbers. To quit StrongForth and return to the ANS Forth host system, type QUIT. You can resume StrongForth.f at any time by executing STRONG. Since StrongForth's dictionary will remain as it was immediately before executing QUIT, you don't have to include the core library again. However, note that StrongForth.f is an application and not a library. You cannot mix StrongForth words and ANS Forth words, because the execution of words that are not defined in the StrongForth dictionary will most likely corrupt StrongForth's data type system. To exit both StrongForth and the ANS Forth host system, type BYE.

Once StrongForth has been started with STRONG, you may include additional word sets and other StrongForth source files like the OOP package. You can also import additional words from the host system with 'HOST, which returns the execution token, and IMPORT, which adds a new definition with a given execution token to the StrongForth dictionary. Take care to provide a correct stack diagram. Here's an example:

'HOST DUMP IMPORT DUMP ( ADDRESS UNSIGNED -- )

If the word to be imported is a parsing word, 'HOST should be replaced with 'HOST-PARSING. 'HOST-PARSING creates a wrapper definition that ensures parsing is done correctly:

'HOST-PARSING SEE IMPORT SEE ( -- )

Questions, comments and new ideas are welcome.

ANS Compliance

StrongForth is not compliant to ANS Forth. The most important differences are that a precise stack diagram is included in the definition of each word, and that many words are overloaded. Other differences between ANS Forth and StrongForth are described in the introduction to StrongForth. See also the ANS Forth to StrongForth cross reference.

StrongForth.f 1.2 contains the following word sets, which have been only slightly modified with respect to the ANS Forth standard:

Note that the Facility, Memory-Allocation and Programming-Tools word sets have to explicitly included, while all other word sets are already contained in strong.f and corelib.sf. The Programming-Tools word set does not contain words related to assembler programming; CODE, END-CODE, ASSEMBLER, and ;CODE are missing. Including the Facility word set may cause an exception to be thrown, because many ANS Forth host systems do not provide all words belonging to this word set. The Object Oriented Programming package, which may optionally be included, requires the Memory-Allocation word set.

Version History

2008-09-29 Version 1.0

2008-10-02 Version 1.1

2009-02-03 Version 1.2

Future


Dr. Stephan Becher - February 2nd, 2009