3 ms·
To me the danger of this kind of one liners is that if you use it 2 times somewhere, someone, at some point, will do the lazy refactor of “let’s put it into a f
by xondono 6y ago
To me the danger of this kind of one liners is that if you use it 2 times somewhere, someone, at some point, will do the lazy refactor of “let’s put it into a function”.
int clamp (int value, int min, int max)
And that one liner inside. And now you have a double evaluation bomb waiting to go out on your codebase.
- geophile 6y agoWhy? You wrote a function, not a macro.
- xondono 6y agoAccidentally overwrote the middle step: Junior developer puts the one liner on google, finds the typical macro definition and does the change.
- adrianmonk 6y agoMaybe they mean that you might have been unintentionally relying on double evaluation, and then you take it away, and something breaks. Because it worked for the wrong reasons.