Closed nlfiedler closed 10 years ago
Look at the Java byte code format [1] for ideas, although Java byte code seems a bit low level. Basically, the primitive expressions in Scheme need to have corresponding byte codes, while nearly everything else is derived from those primitive expressions. The built-in procedures for the various types will continue to be implemented in Go for sake of performance.
Consider the impact this may have on the (read) and (eval) procedures; perhaps eval would perform JIT compilation to byte code.
Consider writing the compiled byte code to a file to avoid compiling the same code repeatedly. See the Java class file format for ideas [2].
[1] http://en.wikipedia.org/wiki/Java_bytecode [2] http://en.wikipedia.org/wiki/Java_class_file
Using Eli Bendersky's "bob" [1] Scheme compiler/interpreter written in Python (ignoring the C++ version for now) as a guide for implementing the equivalent in Go.
Fixed in commit cdbc261.
All of the really cool Scheme interpreters compile the Scheme code to some form of bytecode to improve performance. Some even compile to native code, though that may be a bit far given my resources.