Caterpillar

Daily Thought - 2024-11-07

< back to list

The Caterpillar runtime is a bytecode interpreter. (Right now. Eventually, I want to compile Caterpillar directly to WebAssembly, and later machine code.) It executes instructions that are generated by the compiler. Some of those instructions are quite complicated, which is why the runtime requires dynamic allocation.

I want to replace these complicated instruction with simpler ones, but that means the compiler needs to do more work. Basically, the runtime tracks more information than is strictly necessary, and this information is processed by those complex instructions. My goal is to track that information at compile-time instead, so no more complex instructions are required.

I started with bindings (what many languages call "variables"). I'd like to eliminate that concept from the runtime entirely. To do that, I need to track the arity (number of inputs and outputs) of every expression at compile-time. But that is not as simple as it initially seemed, because the arity of the eval intrinsic depends on the arity of the anonymous function it evaluates.

<< previous thoughtnext thought >>