Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Forth implement the dictionary? (controversy)

I am studying Forth for a personal project I have on my mind. It looks to be a really cool and simple language to implement in a small virtual machine.

I am especially impressed by the possibilities of the use of vocabularies on it. On the other hand, I think the way the dictionary works is overly complex for a language that is overall so simple. I say this, because I have read some papers about it, and I know that much controversy exist.

There are some microprocessors which implement some features of Forth in their instructions, and I am interested to know how they implement the dictionary and features like the vocabulary on them, so I can implement a virtual machine which look like those microprocessors.

That is, the dictionary is not a simple heap which grows up, and is not a simple linear vector which we can simply index, so it is not an easy thing for the microcode of a microprocessor to do (I guess). I would be really impressed if those special processors are capable to implement the dictionary like it should be, without any extra code, of course. I think this is impossible.

So for my project, I am considering to code the interpreter with a heap, with opcodes to manipulate it, like it is for example in the 6852. And the code for the dictionary, shall be compiled along with the interpreter and the editor in Forth. I think this should look more like the reality.

What is all this controversy about? How do these special processors work, with relation to the dictionary and the use of vocabularies?

like image 502
Leandro Jardim Avatar asked Sep 08 '10 03:09

Leandro Jardim


1 Answers

The Wikipedia article on Forth contains a short description on the original implementation of the Dictionary. Also see "Development and Dissemination" in The Evolution of Forth. The original implementation used a linked list. But a hashtable(map) seems to be a better approximation.

like image 134
Vijay Mathew Avatar answered Nov 14 '22 03:11

Vijay Mathew