This is an email from Racket-devel mailing by Jens Axel Søgaard to answer Austin T’s question with email subject “Looking for explanation on Racket’s C code & core systems implementation (hello from Shaka Scheme)”. I found this is very useful, so copy it here. Thanks Jens!
> I would like to know:
> – What should I read?
Since Scheme is an old language the literature on Scheme compilers is surprisingly rich.
Some of the classics (can’t recommend these enough):
“Lisp in Small Pieces” by Christian Queinnec
This book is a delight to read – and even includes a chapter on compiling to C.
“Three Implementation Models for Scheme” by R. Kent Dybvig
Dybvig’s thesis. Very clear explanations. Explains how to implement using a stack of frames (like C).
> – Expressing Scheme types in C data structures
Take a look at how Larceny represents Scheme values. The approach is fairly typical.
> Garbage collection vs. reference counting
Reference counting has problems with cyclic data that becomes dead. A simple stop-copy garbage collector would be a good place to start.
“Programming Languages: Application and Interpretation” (PLAI) by Shriram Krishnamurthi has a chapter on memory management:
(There is a nice language for implementation garbage collectors available. See http://blog.brownplt.org/2013/02/19/teaching-gc.html . I can’t find the linked exercises – have they moved?)
> Parsing input from characters & type of algorithm used
The Scheme Compiler Workshop has a section on writing a scanner and parser:
Jens Axel Søgaard