Forth like interpreter

Samuel A. Falvo II kc5tja at
Mon Mar 13 13:00:18 CET 2000

In article <38CBFA30.E247C266 at>, Christian Tismer wrote:
>Well, that's one reason why I said "no Forth, but TIL".
>There is no need for a Forth dictionary to have a threaded
>language. I have Python's dictionaries, why use something else?

Well, if you were trying to implement Forth, and not a Forth-like language,
Python's dictionaries would need to be ordered by the time the words are
created.  This allows such words as "FORGET" (non-standard word, I know, but
is typical of most Forth environments) to be implemented with proper
semantics.  Furthermore, Forth allows you to "derive" words.  For example:

	: Hello ." Hello" cr ;
	: Hello ." And she said," cr Hello ." World" cr ;

Implementing this using Python's dictionaries wouldn't work, as you'd be
overwriting the previous definition of Hello, not augmenting it like you are

>Forth uses early binding, so I'd go with one lookup and store
>a pointer to the word. I'd do the complete Forth code generation

This isn't always the case.  There are plenty of object system packages for
Forth (one in as little as 15 lines of source, if memory serves me
correctly) which utilizes late-binding.  Certainly nothing of the CLOS
sophistication, but then, with Forth, you don't need that kind of
sophistication anyway.

KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA

More information about the Python-list mailing list