3 ms·
What you get from the flexibility of having macros, it seems like you lose by being unable to do static analysis at any level other parentheses matching? In pa
by skybrian 6y ago
What you get from the flexibility of having macros, it seems like you lose by being unable to do static analysis at any level other parentheses matching?
In particular, consider trying to figure out all usages of a function without executing code. I don't think you can even resolve imports without possibly getting fooled by macros that you didn't hard-code an understanding of?
(But on the other hand, it's not going to be 100% in languages that support reflection either. We just assume that's rare.)
- Firadeoclus 6y agoIf you have access to the whole codebase, and the ability to ask the system for code after macro expansion, you can do any kind of analysis you want.
- skybrian 6y agoOne problem is that macro expansion is arbitrary code execution, which means your static analysis is potentially insecure. But I suppose it could run in a sandbox. A second issue is that the macro-expanded code is a lowered representation compared to to what the user sees. This tends to make user-friendly error reporting harder. Another problem might arise when macro expansion is intermixed with normal execution, making it harder to just expand macros with executing code. Then you can still do a lot in a debugger, but that's quite different than static code analysis.