4 ms·
One thing about forth in a linear file is you can define a word (word is the forth term for subroutine or function), use it in another word, and redefine the wo
by drivers99 4y ago
One thing about forth in a linear file is you can define a word (word is the forth term for subroutine or function), use it in another word, and redefine the word to something else after that without affecting the previous word. (Generally the word list (dictionary) is just a linked list and you search by starting from the newest word.) So I'm curious how the hierarchical words are stored and in what order they are searched.
- Someone 4y agoOne thing about forths is that you can easily change that if you want. The simplest way to handle this is by patching the old word to jump to the new definition. If it bothers you that that leaves junk around, you can write words that compact the dictionary. Alternatively, if you have malloc/free, it’s easy to change the dictionary to be a list of pointers to malloced word definitions, and, when defining a word whose name matches that of an already existing word, to update that pointer to point to the new definition, and then cleanup the old definition by freeing its memory. That may fragment your heap, though, and may affect performance.
- drivers99 4y agoI wasn't saying that redefining words was a bad thing. It's actually great. I'm just wondering how it works in Holonforth. I checked their guide as well.