Hello everyone,<div><br></div><div>For educational purposes, I&#39;ve implemented a simple Scheme interpreter in C, but it&#39;s way too slow at the moment. (eg. just macroexpanding and evaluating a function definition takes a few seconds.) I would like some advice on how to proceed next to get a adequately performing Scheme system.</div>
<div><br></div><div>My goal is simply to get out of C as quickly as possible. ie. Get the basic forms and a macro system working which will allow me to write the rest of it in Scheme.</div><div><br></div><div>So far this is what I have done:</div>
<div><br></div><div>I wrote a simple Scheme interpreter in Scheme in continuation-passing style, so that I can get call/cc working.</div><div><br></div><div>Then I basically just manually translated that code into C. So all continuations are heap allocated. </div>
<div><br></div><div>How should I proceed from here? These are the options that I&#39;ve come up with:</div><div><br></div><div>(1) Optimize variable lookup. Currently the environment is represented as a list of key-value pairs. Variable lookup is done by searching through the list.</div>
<div><br></div><div>(2) &quot;Analyze&quot; the code before evaluating it (ie. as in SICP). Ie. for an (if) form, it will determine that it is an if form during the analysis phase, so that at execution stage it won&#39;t have to repeatedly figure out what sort of form it is.</div>
<div><br></div><div>(3) Write a very simple VM, and develop a simple byte-code compiler.  The problem here is that I don&#39;t really know how to deal with first-class continuations. </div><div><br></div><div>Thanks for your help</div>
<div>  -Patrick</div>