3 ms·
I've always wondered why this isn't a first class language feature. You could make something like JOOQ or LINQ that just hooks the compiler itself at build time
by slackingoff2017 9y ago
I've always wondered why this isn't a first class language feature. You could make something like JOOQ or LINQ that just hooks the compiler itself at build time to extend the language arbitrarily. And no worries about outdated versions, you hooks could also polyfill newer syntax and features if you can hook at parse time.
This would result in a whole new breed of abominations but perhaps something decent would come of it
- rtb 9y agoIt is, in lots of languages. It is usually called "compile time macros" or "macros". In lots of languages the macros run in the language itself, for example in Lisp, Scala or Nim. In C++, compile time macros are run in two separate languages: 1 the "pre-processor" and 2 "C++ templates"