mlscript icon indicating copy to clipboard operation
mlscript copied to clipboard

The next step of code generation

Open chengluyu opened this issue 3 years ago • 0 comments

This issue discusses the next code generation. There are several problems with the current code generator.

  1. The current AST is not standard and incomplete. As the MLscript’s syntax becomes more expressive. We should make use of most JavaScript syntax (excluding the bad parts, of course) in the generated code. The new syntax trees will be generated from Babel’s syntax tree definitions.
  2. Pretty printing must be throughly tested, as there is many trivial indentation and precedence errors in the generated code.
  3. Generate efficient and simple code. Now, we abuse IIFEs. For example, pattern matches and let expressions are translated into nested IIFEs, which are inefficient and unreadable.

After all, the goal is to make code generation more practical. I hope someday we can see a real world project making use of the code generator.

chengluyu avatar Aug 24 '22 12:08 chengluyu