Migrating to VFX Forth

VFX Forth is a major technical upgrade from the ProForth 2.x and other threaded-code Forth compilers. This section describes some of the "gotcha's" in porting code to VFX Forth from ProForth, pre-ANS systems and non-optimising compilers.

VFX Forth is brutally intolerant of programming errors. We have found that this approach, sometimes described as "crash early and crash often", leads to code with fewer lurking bugs. One customer who converted a large application to VFX Forth found that VFX Forth crashes revealed bugs that had been lurking for many years.

VFX generates native code

VFX Forth uses native code compilation with aggressive optimisation. This is perhaps the single biggest difference between VFX Forth and ProForth. Execution speed is a primary goal, and the benchmark figures show that we have achieved it.

Extra care should be exercised with any source code which requires knowledge of the underlying architecure. This will particularly impact definitions which cause compilation and assembler fragments. Many words are provided in VFX Forth to hide the implementation details.

VFX uses absolute addresses

The VFX Kernel runs in absolute address space just like any other Windows/Mac/Linux/DOS application. There is no need to convert Windows addresses to Forth ones using words such as REL>ABS and ABS>REL found in ProForth 2.x and some derivatives.

VFX is an ANS standard Forth

The VFX Kernel is based on the ANS language specification rather than Forth83. This introduces a number of minor differences in the behaviour of the system and the code produced.

COMPILE is now IMMEDIATE

Previous MPE implementations used a non-immediate version of COMPILE which has "unpicked" the following CALL instruction at run-time. This behaviour has been changed.

Comma does not compile

VFX Forth is a native code compiler. Threaded code systems allowed compilation by "comma-ing" a CFA into the dictionary. This is no longer a valid method of generating code. The ANS word COMPILE, should be used instead. Also the system must be in "compile state" when COMPILE, is used.

COLON and CURRENT

Under VFX Forth, the CURRENT definitions wordlist is not modified by COLON (:). Also note that : is no longer immediate.

The Assembler is built-in

The assembler within VFX is built in as part of the kernel since is used by the code generator. The ASM and UNHOOK-ASM directives found in ProForth are redundant. VFX Forth does implement these two directives in a compatibility layer which will write a warning message to the console hinting at non-portable code.

The Inner Interpreter is different

ProForth 2.x applications which relied on or modified the behaviour of the interpreter will not port. VFX Forth has a unified interpreter rather than the C-LOOP and I-LOOP pair.

Both QUIT and INTERPRET are defered for those applications which must override the interpreter/compiler behaviour of the system but they should not be used for any new code.

The FROM-FILE word has gone

ANS specifies the ability to include source-code from ASCII text files. This behaviour is implemented in VFX Forth. The MPE FROM-FILE handler code in ProForth 2 is not supported. Programmers should look at the ANS definitions INCLUDED, INCLUDE-FILE and REFILL to understand the new approach.

Generic I/O

Although KEY and EMIT and friends are still DEFERred, we strongly recommend that you leave them alone because many system tools rely on Generic I/O. This means that you should build Generic I/O tables for all devices you want to use. You can use the examples in LIB\GENIO as models.

External API Linkage

The method used for linking to external library calls has changed radically. LIBFUNCTION: is still supported in the compatibility layer but all new imports should use the EXTERN: syntax described in this manual. The new syntax allows you to bind both C and PASCAL convention definitions, as well as making the job of converting C header files easier.

DLL generation

The mechanism used by VFX Forth is completely different.

Windows Resource Descriptions

All the original MPE syntax for defining Windows resources such as menus and dialog-boxes has been removed in favour of the new parser to handle Windows RC files.

The conversion of "old-style" resources to the new ones must be done "by-hand". The new syntax is cleaner and easier to maintain as well as being largely compatible with 3rd party resource editors.

ANS Error Handling

Error handling in VFX is done using the ANS CATCH and THROW mechanism. The words ERROR and ?ERROR from ProForth 2.x are gone. Please read the section on exception handling both in this manual and the ANS Forth Standard.

Obsolete words

The file LIB\OBSOLETE.FTH contains definitions for many ProForth 2.x words which are not present in VFX Forth.