Ulrich Hoffmann <[email protected]>
Version 1.1.1 - 2015-10-31
This package provides a workbench implementation of Minimal Forth as proposed by Paul Bennett and Peter Knaggs at EuroForth 2015 in Bath.
Their aim is to define a Standard Forth subset suitable for educational purposes. For this they propose to cut down the number of Forth words initially explained to Forth newcomers and only stepwise introduce new concepts such as number output, compiling words, strings, file access, exceptions, ...
This package - the Minimal Forth Workbench - allows to experiment with different sets of primitive (i.e. predefined) definitions in order to further elaborate on Paul's and Peter's ideas.
This implementation picks the appropriate words from a Standard (Forth 94 oder Forth
2012) system (the so called host system) and puts them in a wordlist of their own
named minimal
.
In the end, this wordlist is defined to become the only wordlist in the search
order and also the current wordlist. In essence this makes all other word definitions
from the host system unavailable to the Minimal Forth Workbench.
The source code is seperated into several files:
-
The primitive words of Minimal Forth, to take from the host system. They are defined in the file
primitives.fs
-
Words of Minimal Forth that can be defined in terms of primitives and other Minimal Forth words, i.e. "All that can be built from the primitives". They are defined in the file
secondaries.fs
-
Several word set add-ons in the categories arithmetic, compiling words, control structures, defining words, doubles, error handling, file access, memory words, numeric output, stack operators, string words in files named after the category. Each of these will load independently of the others on top of Minimal Forth. They implement common words in that category by possibly requesting additional primitives from the host system and then building new words on top of them.
-
The Minimal Forth Workbench configuration in the file
prelude.fs
. Currently none of the add-ons is included. You can select any of them to get more functionality. -
The implementation of the word
PRIMITIVE
and the overall setup: fileminimal.fs
. -
A testbench in the file
testbench.fs
which compiles each of the add-ons on its own to check, they compile independently.
As currently setup, the words defined in primitives
and secondaries
are exactly
the words proposed by Paul and Peter with 69 Minimal Forth words.
In addition the words INCLUDE
, WORDS
, PRIMITIVE
, and BYE
that we consider more development environment than language are available.
They are not included in the primitives and word counts.
Your are invited to experiment: remove or add primitives or modífy, add,
remove definitions in secondaries
. Extend and modify add-ons. Define new add-ons.
Please, share your findings.
To use the Minimal Forth workbench just INCLUDE minimal.fs
on any standard system. This makes
the Minimal Forth definitions and only them available. After loading, all defined words still
have their standard meaning - however Minimal Forth is no standard system itself
as it does not provide all definitions from the CORE word set.
$ sf minimal.fs
Minimal Forth Workbench: 48 primitives, 69 words
ok
words ALIGNED CELL+ CHAR+ ROT 2/ LSHIFT XOR OR > = 0= TRUE FALSE MOD 2* / * + VARIABLE
CONSTANT DUP primitive WORDS INCLUDE bye \ .S ( CR KEY? EMIT KEY DOES> ; CREATE :
EXECUTE J LOOP UNTIL AGAIN BEGIN ELSE ' I DO REPEAT WHILE THEN IF R> OVER DROP R@ >R
SWAP RSHIFT INVERT AND < - */MOD CHARS CALIGNED CALIGN C@ C, C! CELLS ALIGN @ , !
48 primitives, 69 words ok
$ sf testbench.fs
Minimal Forth Workbench: 48 primitives, 69 words
...........
All tests passed.
Please send bug reports, improvements and suggestions to Ulrich Hoffmann <[email protected]>
This program conforms to Forth-94 and Forth-2012. It has been verified to load succesfully on SwiftForth, iForth and gForth.
May the Forth be with you!
1.1.1
- Fix issue with TYPE pointed out by Peter Knaggs
- Eliminate dependency on DO LOOP in all other definitions
- Provide defintions for MIN and MAX