4 ms·
Did you just argue that all parameters that will be modified should be copied into new variables? Can't tell if this question is referring to something I said?
by chetanahuja 13y ago
Did you just argue that all parameters that will be modified should be copied into new variables?
Can't tell if this question is referring to something I said? If so, I'd like to know what I said that implied such a thing.
- Dylan16807 13y agoYou seemed to be labeling the uncertainty of whether modifying count affects the caller 'needless cognitive overhead'. The only way to avoid altering the count parameter is to make a new variable for counting.
- chetanahuja 13y agoWell I re-read that comment and it does sound like I'm lumping the call-by-value question with the other needlessly complex stuff (Mainly single line while loop depending on multiple operator precedence issues). Well let me correct myself, I didn't mean to do that. The single line while loop there is just bristling with pitfalls. I'd reject such code in code review and ask it to be rewritten in more readable C. As an added bonus, this exercise would probably also have caught the original bug that started this discussion. The pass-by-value question came from someone who hadn't written C code in years and I'm pretty sure a practicing C coder (in production code) would not have that question in the first place. Or if it does come from a fresh programmer just getting started, it'll only take one code review to get that straight (and probably earn that programme's work some added scrutiny for some time).