BasicsWhat is programming ?
What is Forth ?
Note on operating systems
My instruction set differs from standardized Forth.
- if/then becomes [0 ]]
- for/next becomes [[ 0]
- do/loop is gone
- ^ is exit, ^^ is yield
- ? is fetch, @ is for indexing
- : and ; do only one thing
- ~ switches semantics (compile/execute)
I think those changes were necessary to reduce the noise. Control structure words are not compiled, they create jumps. They better look like symbols than executed words.
Look at it this way, in the C language, the "if" statement really means to compare the value of an expression with 0. If I have to think about the real value that will be passed to "if", to calculate whether the following block will be executed, I might as well write it as such. Hence [0 for if-false and [1 for if-true. It is also shorter and has the mnemonic of a block, terminated with ]].
Another change is colon and semi-colon. They did too much at once. ":" used to parse the next word, define an entry and switch to compilation. Now, it only defines an entry. This allows to use the same technique to define variables and words. The semi-colon ";" is now used to update a definition for later inlining optimization.
In general, eliminating parsing (immediate) words is important, to simplify the language. A side-effect of this design choice is that strings are always put on the stack in the form "address length". That rule is only broken by tick ' and tilde ~ as a convenience.
For an in-depth look at logiqub hacking, consult the hacking book .