Subject: Re: Beginners Question
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 12 Oct 2002 20:22:05 -0500
Newsgroups: comp.lang.scheme
Message-ID: <g--dnYtPFqwgVzWgXTWcqg@News.GigaNews.Com>
WebsiteWill <websitewill@cox-internet.com> wrote:
+---------------
| Found some helpful code there. Now to make translators to core expressions
| for the derived expressions and, or, cond, do, let, let* and letrec. Not
| exactly a trivial task.
+---------------

The *simplest* way I know of -- though your instructor might consider it
"cheating" ;-}  ;-}  -- is probably to write a Scheme interpreter in Icon!!
That at least should be pretty straightforward, especially if you copy
it (loosely) from either the original Sussman/Steele Scheme paper or
from SICP2, say. Icon can do the lexical-parsing part of a Scheme reader
easily enough, which takes care of most of the messy part.

Then within that interpreter, define the derived expressions as *Scheme*
macros that expand to core Scheme, and provide the library function
"macroexpand". Then, in your Icon-hosted Scheme interpreter, the
assigned task becomes simply:

	(with-input-from-file "foo.scm"
	  (print (macroexpand (read))))

Really, doing the Scheme reader in Icon is the hard part. After that,
the rest ("eval", "apply", etc.) is pretty straightforward...


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://www.rpw3.org/>
San Mateo, CA 94403		(650)572-2607