My Fifth Rethink on Execution Tokens

In which I continue my war against associated values In my previous post, I ended by trying to eliminate the CompiledWord cases that use associated values. These are: case parsedLiteral(Int) case undefined(Word) case redefined(Word) case definition(Cell) I've got rid of the last of these, but it was a difficult struggle. I did it by introducing … Continue reading My Fifth Rethink on Execution Tokens

Forth: Cleaning up the execute loop

In which I simplify the execution cycle Every word now has an execution token and most words are interpreted using the function execute(token:,wordStream:,index:, output:). There are still a couple of words that have to be executed outside of this due to their CompiledWord having an associated value. Thus we have this ugly bit of code: … Continue reading Forth: Cleaning up the execute loop

The return of the Forth

In which I discover the return stack The return stack is used in many Forth systems to record return addresses when executing defined words. We currently don't need this because the return stack is implicit in the Swift stack. However, the return stack can be used for temporary storage. Furthermore, at some point, we would … Continue reading The return of the Forth