Between 2000 and 2008, Dr Stephan Becher worked on a strongly typed variant of Forth named StrongForth.
Homepage: StrongForth Homepage
Introduction: Introduction To StrongForth
StrongForth augments Forth by adding type information to the data stack (in a separate “interpreter” heap area and a “compiler” heap area - the actual data stack is not changed, and compiled words don’t shuffle any type information, but the stack effects in word definitions are now binding).
The StrongForth approach looks somewhat interesting when dealing with modern Forth derivatives like Retro or UXN. There are two ways where even a basic type system can help Forth:
- UXN is very unusual because it has both 8 and 16-bit sized cells. The type information can help avoid accidentally using the wrong sized opcode.
- More interestingly, StrongForth allows generic words (in the style of Common Lisp), where the type information on the stack selects one of several identically-named words. This seems like it could get us a very cheap equivalent of object-oriented style on a very simple stack machine.
StrongForth’s types aren’t really “strong” in the sense of providing anything like a security guarantee; they can always be overridden via explicit casts. But they can probably make a Forth much more pleasant to use for beginners at an interactive level.