4 ms·
When is shadowing is right thing to do? Why picking a new variable name wouldnt work?
by shultays 6y ago
When is shadowing is right thing to do? Why picking a new variable name wouldnt work?
- naikrovek 6y agoNo matter what I say here, I feel it would be very likely you will tell me I'm wrong.
- shultays 6y agoI am skeptical but curious. I honestly can't think of one. The closest one I can think is maybe you have some kind of macro that uses a temp variable? like a swap macro? But i think you can still have a unique variable name for that particular line if you want? But if these cases are exceptional then you can use pragma to suppress those warnings for that particular block of code. If they are not exceptional perhaps you shouldn't have enable the warning/linter check for that warning. But honestly I can't think a good reason for shadowing variables and would appreciate an example