Fail translation with typing error in RascalMPL

37 views Asked by At

I am currently working with TypePal for static typing of a DSL. What is a good practice on how to wire up my code generation script, such that if the checker finds error it should fail to proceed to generating code?

1

There are 1 answers

3
Jurgen Vinju On
  • if you can generate correct code for 90% of the program, and you have to skip or generate a throw for the last 10% then people will be able to run the code and play even though it was not 100% correct. This kind of gradual experimenting ability is often appreciated by DSL users
  • if you must guarantee the security or stability or robustness of the generated code, then you have to make sure the type-checker is a quality gate for code generation.
  • or, if you can guarantee that you will throw an exception where code is not proven to act correctly, then you can combine the two.
  • some DSL compilers have modes where in "debug" mode you do the first option while for "run" (deployment) mode you insist all the errors have been fixed.
  • you can also play with the difference between "warnings" and "errors" and "info". With warnings you can still generate working code, while with errors all bets are off and you have to generate throw or stop the compiler.