3 ms·
> any kind of metaprogramming whatsoever I am personally on the fence about this one. It's tremendously useful when writing code, and I've done quite a fair sh
by Joker_vD 3y ago
> any kind of metaprogramming whatsoever
I am personally on the fence about this one. It's tremendously useful when writing code, and I've done quite a fair share of it myself; but on the other hand, when you are reading the code, trying to understand what the hell is actually being called and why, it really sucks when your F12 bottoms out at some meta-generic piece of machinery that invokes something when called from somewhere but what and where, exactly, is a mystery that requires a global search over the repo in the best case (in the worst case there is either nothing to search on or the search term will turn up thousands of hits).
- tgv 3y agoTo me, meta-programming should not creep into a function. It's ok to generate functions or initializers or whatever with it, but it should not be an inconspicuous part of an otherwise normal function body, especially not if it affects control flow. If it really, really helps readability, perhaps it could be used at the top level, but not inside a loop or conditional statement. I might make an exception for complex type declarations. But, like all programming: it should help readability and it should help to avoid bugs, not be used for its own sake, aka cleverness.