▲ | Someone 2 days ago | |
> We can categorize things: > IMMEDIATE words used here are : ( if then ; `:` normally isn’t immediate > First up is `:`. `:` is an IMMEDIATE word, so the compiler just calls it now `:` gets executed because the interpreter, when it isn’t compiling, goes through a loop:
So, `:` gets called in step 3a.> Now the compiler sees `0`. This is a literal token, so we don't even bother with the symbol table; we special-case code to push this value on the stack. As indicated above, that’s not how ‘normal’ forths work. A lookup is done for a word named `0`, and if it exists, a call to it is compiled. Many forths had words named after small constants such as `0`, `1`, `2` or `-1` because compiling a call to a function took less memory than compiling a call to the “LIT” function and compiling the constant value. |