9 Should I use Gforth extensions?
As you read through the rest of this manual, you will see documentation
for Standard words, and documentation for some appealing Gforth
extensions. You might ask yourself the question: “Should I
restrict myself to the standard, or should I use the extensions?”
The answer depends on the goals you have for the program you are working
- Is it just for yourself or do you want to share it with others?
- If you want to share it, do the others all use Gforth?
- If it is just for yourself, do you want to restrict yourself to Gforth?
If restricting the program to Gforth is ok, then there is no reason not
to use extensions. It is still a good idea to keep to the standard
where it is easy, in case you want to reuse these parts in another
program that you want to be portable.
If you want to be able to port the program to other Forth systems, there
are the following points to consider:
- Most Forth systems that are being maintained support the ANS Forth
standard. So if your program complies with the standard, it will be
portable among many systems.
- A number of the Gforth extensions can be implemented in ANS Forth using
public-domain files provided in the compat/ directory. These are
mentioned in the text in passing. There is no reason not to use these
extensions, your program will still be ANS Forth compliant; just include
the appropriate compat files with your program.
- The tool ans-report.fs (see ANS Report) makes it easy to
analyse your program and determine what non-Standard words it relies
upon. However, it does not check whether you use standard words in a
- Some techniques are not standardized by ANS Forth, and are hard or
impossible to implement in a standard way, but can be implemented in
most Forth systems easily, and usually in similar ways (e.g., accessing
word headers). Forth has a rich historical precedent for programmers
taking advantage of implementation-dependent features of their tools
(for example, relying on a knowledge of the dictionary
structure). Sometimes these techniques are necessary to extract every
last bit of performance from the hardware, sometimes they are just a
- Does using a Gforth extension save more work than the porting this part
to other Forth systems (if any) will cost?
- Is the additional functionality worth the reduction in portability and
the additional porting problems?
In order to perform these considerations, you need to know what's
standard and what's not. This manual generally states if something is
non-standard, but the authoritative source is the
Appendix A of the Standard (Rationale) provides a valuable insight
into the thought processes of the technical committee.
Note also that portability between Forth systems is not the only
portability issue; there is also the issue of portability between
different platforms (processor/OS combinations).