DNW's Forth Page
Revised: July 15, 2010
Randolph Peters' short and
elegant Pocket-Forth packages:
Case, OO, Struct.
approaches to strings in Forth by George Hawkins, Rj
Brown, and Marcus Gabriel.
- Pattern by
Wil Baden is an interesting macro processor. His Tool
Belt also has string words that have become classic,
and there are more in his
String Handling with Generalization of SKIP and SCAN.
- A Model for
Dynamic Strings, the ideas underlying our dynamic
Words, our glossary specification. There is an implementation in C for
pfe, included in Guido Draheim's current
distribution. There is also an ANS Forth implementation.
- Guido Draheim has implemented a word set for
zero terminated strings in pfe.
- Gary Chanson's
Quest32 development system contains an extensive
string package based on a string stack.
- Parsing library,
ANS Forth implementation for ANS Forth strings, represented
on the data stack by (addr len), and the input stream. A
consolidation of old words of ours, with some from Wil
Baden's Tool Belt and other sources. There is also a C
implementation as a pfe
strings, a collection of mostly small libraries
implemented in ANS Forth for safe string storage with
concatenation, including the input stream across lines,
using a cell-counted memory representation.
Structures. There have been
many approaches, and the following list is certainly incomplete.
John Hayes and Marcel Hendrix are prominently mentioned in these
links. Common practice has disilled a simple and elegant
approach that was
standardized in Forth 200x in 2007.
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.
Structures by Randolph Peters (already mentioned
above) is the first I know of that has reusable element
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.
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.
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.
Structures is a short library based on the Forth
200x standard. It includes an early binding method for
optimizing compiled structure references.
Named Structures implements a simple wordlist
management scheme for reusable structure field names.
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
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
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
- We also did a pfe
port of JVN's lexicon, including the Kahan algorithms.
correctness tests of the lexicon are based on a
floating point extension of John Hayes' ANS Forth
tester program called
- Zelefunt, a
collection of programs that ports W. J. Cody's Fortran
celefunt package, tests the accuracy of some of the complex
- 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 implementation of a 2009 proposal for IEEE floating point.
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