3 ms·
Ah, but which assembly? If you just roll a simple VM in the host language, your instruction set becomes the assembly Forth integrates so well with. I'm assuming
by johnecheck 1y ago
Ah, but which assembly? If you just roll a simple VM in the host language, your instruction set becomes the assembly Forth integrates so well with. I'm assuming that's what they did in their C implementation.
- anyfoo 1y agoTrue! I don't think that's what happening, though. At a quick glance, the primitive words seem to be directly implemented in C: https://github.com/eliben/goforth/blob/3949fe0cc52131fdcae0e38ac5f6aee596056d3b/ctil/builtins.c#L106 https://github.com/eliben/goforth/blob/3949fe0cc52131fdcae0e... So it looks like this one kind of sits in between. It has primitive words implemented in C, but a dictionary accessible by Forth. The interpreter loop however seems to be implemented in C as well, not Forth.
- johnecheck 1y agoI remember when I realized just how little host language code was needed to bootstrap a Forth. Before that I was making the same mistake. OP, I strongly recommend the book Threaded Interpreted Languages [1]. I had to read chapter 2 several times before it clicked (short and dense), but it's an excellent resource. [1] https://archive.org/details/R.G.LoeligerThreadedInterpretiveLanguagesTheirDesignAndImplementationByteBooks1981 https://archive.org/details/R.G.LoeligerThreadedInterpretive...