> Have you ever designed at length how to implement a super fast
> *interpreted* version of metaocaml, or let me put it this way: do you
> think if that is possible at all?
I guess you are asking about the complexity and overhead of building
code representations (because otherwise, MetaOCaml is an ordinary
OCaml program, and could be optimized as such). Code values have a
somewhat complex representation because they also describe all
future-stage free variables that occur within the value. The data
structure used to represent free variable is designed to be
efficient. Long time ago I did a spot test of generating code with 100
free variables. I could not detect any overhead due to the handling of
free variables. Thus in my experience, MetaOCaml-specific overhead is
rather negligible. If there is a real need to get MetaOCaml to generate
code as fast as possible, one should optimize MetaOCaml as any other
OCaml program.
You may also be asking about the performance of Runcode.run. It
includes compiling the code and running the resulting
bytecode. Compilation does impose overhead. How to reduce it is a
complex question. For now I remark that the generated code is usually
rather simple. One could compile it with rather old version of OCaml,
which was really fast.