On Wed, Jan 16, 2008 at 11:03:30PM -0800, [EMAIL PROTECTED] wrote:

A nice test of one's understanding of Scheme
evaulation would be to write your own interpreter or REPL in your favorite
scripting language.  The print and loop parts of the REPL are trivial.
The read machine may involve some parsing.  Perhaps flex/bison would be best
there.  That then leaves the evaluate machine.

I take it you haven't read through the whole book :-)

Later chapters implement a compiler from scheme to a kind of invented
machine code.

As far as parsers, flex/bison would be drastic overkill.  The tokenizer is
quite simple even, since most characters are separated by just a few
others.  The _only_ structure to the grammar are lists, which is just a
simple recursive parser.

The whole thing can be implemented in a few dozen lines of code, at least
in scheme (I'm talking about not calling read, but implementing it
yourself).

Trying to write a lisp/scheme compiler in a non-lisp language would much
more challenging, and not really have much point.  There is a nice
advantage that the language structure is the same as the data
representation makes compilers a lot easier.

I think the best way to see if you understand Scheme evaluation is to
continue writing code in it.  The book will build to the point where you
will be writing eval/apply anyway.

Dave

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to