Thanks for all the suggestions! I'll look over those and see what's happening.<div><br></div><div>I have profiled my code, and noticed that it spends most of the time in typechecking the arguments to the cons, car, and cdr primitives. I currently know of no simple way to eliminate those checks while still giving me relatively sane error messages for when things go wrong.</div>
<div><br></div><div> -Patrick<br><br><div class="gmail_quote">On Mon, Mar 21, 2011 at 1:39 PM, Vincent St-Amour <span dir="ltr"><<a href="mailto:stamourv@ccs.neu.edu">stamourv@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
David Kranz's dissertation has a lot of interesting material about<br>
implementing closures efficiently.<br>
<a href="http://repository.readscheme.org/ftp/papers/orbit-thesis.pdf" target="_blank">http://repository.readscheme.org/ftp/papers/orbit-thesis.pdf</a><br>
<br>
Andrew Appel's book Compiling with Continuations also covers similar<br>
material.<br>
<br>
Vincent<br>
<br>
At Mon, 21 Mar 2011 12:42:07 -0400,<br>
Patrick Li wrote:<br>
><br>
> [1 <multipart/alternative (7bit)>]<br>
> [1.1 <text/plain; ISO-8859-1 (7bit)>]<br>
<div><div></div><div class="h5">> Hello everyone,<br>
><br>
> For educational purposes, I've implemented a simple Scheme interpreter in C,<br>
> but it's way too slow at the moment. (eg. just macroexpanding and evaluating<br>
> a function definition takes a few seconds.) I would like some advice on how<br>
> to proceed next to get a adequately performing Scheme system.<br>
><br>
> My goal is simply to get out of C as quickly as possible. ie. Get the basic<br>
> forms and a macro system working which will allow me to write the rest of it<br>
> in Scheme.<br>
><br>
> So far this is what I have done:<br>
><br>
> I wrote a simple Scheme interpreter in Scheme in continuation-passing style,<br>
> so that I can get call/cc working.<br>
><br>
> Then I basically just manually translated that code into C. So all<br>
> continuations are heap allocated.<br>
><br>
> How should I proceed from here? These are the options that I've come up<br>
> with:<br>
><br>
> (1) Optimize variable lookup. Currently the environment is represented as a<br>
> list of key-value pairs. Variable lookup is done by searching through the<br>
> list.<br>
><br>
> (2) "Analyze" the code before evaluating it (ie. as in SICP). Ie. for an<br>
> (if) form, it will determine that it is an if form during the analysis<br>
> phase, so that at execution stage it won't have to repeatedly figure out<br>
> what sort of form it is.<br>
><br>
> (3) Write a very simple VM, and develop a simple byte-code compiler. The<br>
> problem here is that I don't really know how to deal with first-class<br>
> continuations.<br>
><br>
> Thanks for your help<br>
> -Patrick<br>
</div></div>> [1.2 <text/html; ISO-8859-1 (quoted-printable)>]<br>
><br>
> [2 <text/plain; us-ascii (7bit)>]<br>
<div><div></div><div class="h5">> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
</div></div></blockquote></div><br></div>