unseemly icon indicating copy to clipboard operation
unseemly copied to clipboard

Add a compiliation phase, as an alternative to evaluation

Open paulstansifer opened this issue 6 years ago • 1 comments

The object language will probably be Rust, in order to be able to avoid reimplementing certain chunks of the runtime.

We will need to add a compile walk (expressing some object-language code) to every Form that defines an eval walk. That's pretty straightforward, if a little long.

We would need to modify the ast_walk infrastructure to reify the various things it does to the runtime values. In particular, we'd need a reified version of freshening. (If the object language is Rust, we could just use unseemly::alpha.)

We will need to reify Unseemly values into the object language. If the object language is Rust, can we just use the existing reifier? I think so, except that we're missing the ability to translate Unseemly types into Rust types, which we'll need for type annotations.

Of course, compiling to an actual intermediate language (like LLVM) would be better, but it would be a lot more work. Bootstrapping an actual compiler is possible, even if the Rust implementation remains an interpreter, but I suspect the sheer slowness of this implementation would overwhelm such an effort, in that case.

paulstansifer avatar Jun 15 '19 20:06 paulstansifer

Now I think that compiling to a high-level language is probably a bit of a false economy. As issue #35 argues, having few core forms makes it easier to write a backend, so why not pick something low-level to get faster compile times, fewer dependencies, and more control?

Backends to consider:

  • LLVM
  • Cranelift
  • BEAM

There's some runtime code that would need to be reimplemented; probably the easiest solution would be to rewrite that code in Unseemly.

paulstansifer avatar Jan 22 '20 02:01 paulstansifer