What is P0cForth?
P0cForth is NOT another (full) Forth implementation. It is a only minimalistic Forth like system and my idea about P0cForth, I respect other ideas about minimalistic Forth and even opinion that this is so minimal that it is not a real Forth system. That is why it has a 0 in it name.Why P0cForth?
For a long time I was thinking what Forth words are minimal needed to code to create a Forth (like) system. There are guides what Forth primitives need to be created to bootstrap a full Forth system. However I wanted a minimalist set of Forth words. Not to bootstrap a Forth system, only as a proof of concept for a Forth system that can be extended. A search on internet gives information about several interesting minimal Forth systems. Even systems minimal systems including @ ! however that is not what i wanted.Also wanted to give it a name. I decided for P0cForth , "Proof of concept Forth" , i changed the o to 0.
It is to have bare minimal system that is relative easy to build (and can be extended) to have a proof of concept Forth system.
What words/code need to be in P0cForth?
In the Forth2020 Zoom meeting on 9 januari 2021 Dr Ting talked about Jeforth 2.01.He mentioned a minimal system with 9 Forth words
: ; * . , dup dolit ret here
He also presented simple demos:
: square dup * ;
: quad square square ;
; octet quad quad ;
8 octet . 4 octet .
I used this 9
words as a start for P0cForth., However, I want to
reduce it even more.
So I ended up with this 5 words:: ; * . dup
I decided to reduce the system even more by omitting the interpretation of numbers defining (some) numbers direct as words. This would decrease the programming code and logic. And yes when extending the proof of concept Forth real handling of numbers would be useful and literals and dolit can be very useful. However I wanted to reduce it as much as possible. Literals are a very useful method of implementation, however i did not want to force this as a solution for handling numbers in my definition of P0cForth.
The code created for a number as a Forth words for a target system can be easy copied and adapted for another number. So it could be easy extended to include a lot of other numbers. However i wanted it to as minimal as possible.
With * and -1 it can be and easy extend it to numbers in the range -4 to 4 (However if you continue reading to the end you will see this idea was wrong. Only one very special number is sufficient to create all numbers!)
: -2 -1 2 * ;
: -3 -1 3 * ;
: -4 -1 4 * ;
Also the demo mentioned above can be tested (after creating 8)
: quad square square ;
; octet quad quad ;
8 octet . 4 octet .
Adding code for a + function would make it possible to extend the number range even further without having gaps.
My first idea of a minimal P0cForth that could be a first start for a minimal Forth as5 ‘number words’ -1 0 1 2 3
Creating e.g. a text input stream processor with this 6 different type of words would give a proof of concept system that could be used as a basis to create a full Forth system.
Two facts made me not complete happy with this set of words.- The possibility to build a complete Forth with these words is missing. it is only possible to extend this Forth by changing the 'external' code and add more words. However this minimal words can be a good basis of a proof of concept when creating a new Forth.
1 is not needed as it could be defined by the other words
: 1 -1 dup * ;
: 2 1 dup + ;
P0cForth minimal wordset
: octet quad quad ;
8 octet .
A simple option would be to reduce the word set would be omitting ; and have a the new definition, that in Forth starts with the colon : close always at the end of the line.