Hacker News new | past | comments | ask | show | jobs | submit login

One way to do dynamic macro in static type language is to generate the source code using the host language as separate build process before the compilation of hand-written and generated source code.

For example in Typescript, I use tsc-macro to run "*.macro.ts", they can import any functions and modules just like normal source code. And their evaluated result are saved as "*.ts"

The generated ts are then compiled alone with other hand-written typical source files into js for deployment and execution.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: