Compiler/Interpreter Work Writeup

What are these, exactly? Do you have a brief summary/writeup (or could you summarize here)?

Hi. Limitations by language:

  • In L2C: functions are similar to Rust functions (fn) in the specific sense that they cannot access the local variables of parent functions. This is because they are denested and compiled into ordinary top-level C functions. The DSL’s nesting is still useful to allow inline definitions of functions at their point of use. Nesting is also useful to control the scope of function definitions.
  • In Elixir DSL: functions are more like Rust closures in the specific sense that they can access the local variables of their parent functions. This is because they are compiled using GCC nested functions. These functions are a little unsafe because they cannot outlive their parent functions, or in other words closures cannot escape. Escape attempts will result in segmentation faults. This limitation is due to GCC’s implementation of nested functions using trampolines on the stack.
  • In L2C: full continuations are not supported. Only escape continuations are supported - i.e you can only call a continuation to exit the current scope. (This functionality could probably be generalized to support jumping up and down the current call stack.) I chose this approach because full continuations seem to be more complex to compile seemingly requiring that the full state of the stack be saved for later use - and this probably would not be efficient.
  • In Elixir DSL: no continuations are supported. They could be supported to some extent through escape continuations, but were not included in @l4e21 ‘s Elixir DSL. Probable reasons for their exclusion: not required by users, and the fact that it’s probably an unusual variation to call/cc.
  • No garbage collection. Garbage collection for compiled DSL programs should be possible, but might cause noticeable slow down within the zkVM. I guess we still have to figure out what specifically caused the Chicken Scheme experiments to be so slow.

So briefly: no garbage collection, closure’s must not escape, and continuations are invalidated when their stack frames dies. Also, a few minor syntactical changes were made to simplify the interpreter and compiler work. So this language is not quite Scheme nor is it C.

What is “S@Jamheme code” (maybe a typo)? Do you have a few small examples of this?

Thanks, this is a typo - my mistake. I meant that @l4e21 had already defined a DSL and written an interpreter for it at the time when I started writing the compiler. So the compiler had to conform to this language as much as possible.

Examples of the DSL:

1 Like