DNW's Forth Page
Revised: July 12, 2006
Randolph Peters' short and
elegant Pocket-Forth packages:
Case, OO, Struct.
Strings
Structures. There have been
many approaches, and the following list is certainly incomplete.
John Hayes and Marcel Hendrix are prominently mentioned in these
links. Some practitioners feel that the simplicity of defining
what you need for a particular application in Forth outshines
any need for a standard specification. But there are some fairly
simple and useful implementations.
-
Structured Data with Bitfields by Mitch
Bradley is an early and lean implementation of structures,
including bit fields. It includes more historical
references. Part of his approach has become a common
practise, my understanding of which is in Plain Structures.
- Data
Structures by Randolph Peters (already mentioned
above) is the first I know of that has reusable element
labels.
-
Yet another Forth structures package by
Anton Ertl is a nice discussion of the essential
requirements; and he provides a short, useful ANS Forth
implementation. I believe the support for structures in
Gforth grows out of this.
- A
Rationale for Structures in the Forth Scientific
Library by Skip Carter is a guide to structures in
the (FSL) project,
implemented in ANS Forth. It treats some issues of
early and late binding.
-
Structure Words by Guido Draheim is a helpful
survey of structure implementation practises from various
sources, from which he extracts some guidelines. He
implements them in
pfe in two word sets,
Struct, for neon/mops/mpe-like structures with
Gforth compatibility extras, and
Structs, for fsl/mforth-like structures.
- Compatible
Structures in ANS Forth (PDF, 156K) is my
description of a structure word set aimed at compatibility
with C structures. It's an elaborate business, with
conditional compilation in the implemention to select the degree
of elaboration. Since I have switched to C-based Forth's,
the problem the full package aims to solve has mostly
disappeared for me. Various subsets, including a small
kernel which is an ANSification of Peters' work, may be
useful in a general Forth environment.
- Quick and Dirty
Structures is one of the schemes I have actually used.
Lists. So far we only have a
link to our own. We'll include more as we become aware of them.
Forth to C translation. We know of only three such
translators, including our own.
-
C Without C, part of
Rob Chapman's ambitious
Timbre rule-based translator project. It was the
earliest, and the project is well developed and still active.
-
Forth2C by Anton Ertl and Martin Maierhofer. This
is a prototype translator for the principles described in
Translating Forth to Efficient C, which
are validated by the benchmark studies included there.
- ^Forth to
C, our macro-based translator written in Forth,
currently implemented with pfe and the dynamic-strings
package. ^Forth
Words contains a rationale, basic specification, and
short examples. An extended example is a version of the Gforth suite
of four traditional benchmarks, with C source output to be
compiled and linked with pfe. Currently we have results only for Mac OS
X/Darwin.
Complex arithmetic and elementary functions
- Links to our revisions of Julian V. Noble's complex
lexicon to include OpenMath principal expressions for the
inverse functions, and Kahan extended accuracy algorithms,
are included on a separate
page.
- We also did a pfe
port of JVN's lexicon, including the Kahan algorithms.
- Formal
correctness tests of the lexicon are based on a floating point extension of
John Hayes' ANS Forth
tester program.
- Zelefunt, a
collection of programs that ports W. J. Cody's Fortran
celefunt package, tests the accuracy of some of the complex
functions.
- Borda's mouthpiece,
a Forth treatment of an example by William Kahan showing how
signed zero can help calculations on branch cuts.
External modules for pfe. Besides
the dynamic string and complex math modules which are part of
the pfe distribution, we have written a few external modules. Among them
is an experimental interface to C99 floating point extensions.
kForth in MacOS X. We did a port of Krishna
Myneni's kForth to the PowerPC under MacOS X. Our main
contribution was the ppc assembly
language code for the virtual machine, including Forth
primitives and mixed precision division
subroutines, plus a number of tests.
While we still use pfe as our main Forth system, we're
impressed by kForth's relatively lean design among C-based
Forth's. Its byte-code threading scheme allows control
structures and return stack manipulations that are normally
compilation only to work also in interactive mode. And its performance on the standard
four benchmarks is quite decent. We get a user time ratio of
about 4.00 for kForth-fast 1.4.0 compared to gforth-fast 0.6.2
on our dual-G4 osx system, and 2.86 on a tri-i686 linux system.
David N. Willliams' home
page and
Forth archive.