5 ms·
When would shadow binding help create more readable code? (I agree with everything else in your post)
by Abhinav2000 6y ago
When would shadow binding help create more readable code? (I agree with everything else in your post)
- zelphirkalt 6y agoI think it would do that, if in the inner scope, you only need a part of something from the outer scope. Lets say you have a list of things and they have the name according to what they are, lets use "things" as a placeholder. Then in the inner scope, you are still working with "things", just not all of the outer scope, but for reading the code of the inner scope, it does not matter. You are still working with "things". OK, this is quite abstract. I am thinking about it in something like nested named lets, where you make a functional update to something, that comes from the outer named let, inside the inner named let and then use it as an argument to a procedure call. Situations like that. And perhaps only, when it is difficult to name this subset of things anything else than the original name. If there is easily available another fitting name, then I would always go for that. It does make renaming things harder though.
- dmohs 6y agoYes it does make renaming harder, but if your compiler warns about unused variables it might save you more often than not.
- Abhinav2000 6y agoThanks