Jon Riehl’s Log

Thursday, March 5, 2009

The ALT-G Bitbucket Repository

If you are not following the ALT-G group, I’d like to announce that source code for the Camlp5 source-to-source translator is available on Bitbucket at  Specifically, you’ll find it in the camlp5 subdirectory.

If you dig the Camlp5 stuff, the viscomp subdirectory might also be of interest.  In there I give an example of taking apart the read-eval-print loop for the SML/NJ compiler.  This decomposition draws a line between the front-end (parser) and the back-end (everything else).  This separation gives me several things: a parser for SML/NJ (not too hard to get a hold of, but I did have to go digging), and an evaluator that can operate on either strings or SML/NJ abstract syntax.  It should come as no surprise that, following my SML/NJ investigation, my attention has turned to source-to-source translation.

One idea I take from my work on Mython, is applying the evaluator at compile time.  A lot of other people seem to avoid doing this, and I’m still a little curious why (other than old reservations about binary size).  Camlp5 could have incorporated parts of the Ocaml compiler to get parse-time evaluation, and this would make its “#pragma” declaration much more useful.  If I understand correctly, Camlp5 wanted a clean break with the Ocaml code, so they have developed an interpreted evaluator that is not complete (at least for the version I was using).

In conversations I’ve had with John Reppy, he also seems to prefer not coupling a programmable front-end with a specific evaluator since the front-end would become saddled with limitations of the evaluator (SML/NJ’s 31-bit integers were one example given).  I’ll certainly have to think more about this design point, and would be interested in hearing more about the pro’s and con’s of general purpose compile-time evaluation (other than the obvious limitation that user code can now cause the compiler to not halt).

posted by jriehl at 11:25 am  

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress