100 Days of Code Day 45
It took me a long time, but I finished the Forth interpreter subset. I had to refactor a bit. All of the math and stack operations got turned into functions called from a prepopulated symbol table. Otherwise several of the tests would fail. I also had a problem where if you redefine a word with a function body that calls the word, you get an infinite loop that kills the program. Now each word has a snapshot of the symbol table they were defined with so that it calls functions as it knew them at the time of definition. Seems like a hack but it worked.
I looked at some of the other community solutions. They were so short. I wonder if they really passed the tests or not. I think you could add more stuff to my version easier than theirs.
Would I use the Sprache library again? It did work well. However, it doesn’t look like it has been updated in at least four years, and the code examples do give me a headache. A solid maybe.
