[comp.lang.forth] Forth in Lisp

jlj@wheaties.ai.mit.edu (Joseph Lee Jones) (03/22/90)

We are working on a project at our lab involving a small mobile robot.
We hope to use a single board couputer with a 68HC11 processor running
Forth to control the robot.  For development purposes it would be
advantageous for us to have a version of Forth implemented in Lisp.
Does any one know of such an implementation?  Prefferably in the
public domain?

							Joe Jones

sdh@flash.bellcore.com (Stephen D Hawley) (03/22/90)

In article <7387@wheat-chex.ai.mit.edu> jlj@wheaties.ai.mit.edu (Joseph Lee Jones) writes:
>We are working on a project at our lab involving a small mobile robot.
>We hope to use a single board couputer with a 68HC11 processor running
>Forth to control the robot.  For development purposes it would be
>advantageous for us to have a version of Forth implemented in Lisp.
>Does any one know of such an implementation?  Prefferably in the
>public domain?
>
>							Joe Jones


That's a really warped idea, but it turns out to be not so hard.  I don't
know of any version that is currently available, but you should be able to
really whip one out by defining your dictionary as a list of words.  Each
word would be a list containing the name, flags, link, pfa, cfa and code.  The 
parameter and return stacks would also be lists.  To push, cons the new
entry onto the list.  To pop,use the cdr of the list.  The only words that
would give you any sort of trouble are address using words like ' @ ! etc.
but I'm sure a neat abstraction could be whipped up.

Excuse my lisp syntax, I'm used to scheme as a dialect.
(define dictionary '(
	...
	('* () '- () () (prim 'forth*))
	('- () '+ () () (prim 'forth-))
	('+ () () () () (prim 'forth+))
))

So you could use this as a dictionary prototype.  The prim marker would mean
that the next atom is the name of an executable lisp function.

(define forth+ (lambda () (push (+ (pop) (pop)))))

Cool beans.  I leave the rest as an exercise for the astute reader.

Steve Hawley
sdh@flash.bellcore.com
"I'm sick and tired of being told that ordinary decent people are fed up with
being sick and tired.  I know I'm certainly not, and I'm sick and tired of
being told that I am."