Exploring Different Representations for Code
Overview
Multi-stage programming is a convenient way of adding annotations to programs to direct partial evaluation. MetaOCaml is a implementation of a multi-stage programming language built on top of OCaml. This project aims to explore different representations for MetaOCaml's code type, primarily by way of Peter Thiemann's code splicing. By exploring different representations of code, we give the programmer flexibility to choose the most appropriate representation for his or her particular application domain. Some examples of what different strategies in representing code have to offer are:
- fast compile times, perhaps sacrificing runtime performance
- fast running times, perhaps at the expense of added compile time
- ability to “peek inside the code” to understand what the staging constructs are generating
Implementation
We have built a small interpreter for the multi-stage lambda calculus that implements several of the schemes described in Thiemann's paper. Preliminary performance results indicate that these schemes may be quicker to compile than the reprensentation MetaOCaml currently uses for code, although slightly slower in terms of actual run-time performance.
Source Code
You may download the current source code for the project.
Paper
You may download a short paper describing the current implementation and some performance results. This was the report submitted for the Multi-Stage Programming class for which this work was done.
Limitations
We currently do not support levels greater than 1 in the interpreter. Work to fix this is in progress.