Re:Should function arguments be reassignable or mutable?
by weinzierl on Monday January 01, 2018 @10:33AM
(#16046398)
The warning says it right away, the first a is shadowed, not reassigned, here.
The difference is that when a is reassigned the 7 is lost, while it should be still around when shadowed. I don‘t know of a way to access the 7 in this example however.
Re:Should function arguments be reassignable or mutable?
by runeks on Monday January 01, 2018 @04:34PM
(#16048171)
If there’s no way to access the 7 after it’s shadowed, why couldn’t an optimized garbage collector throw it away after it’s shadowed, thus making it equivalent to reassignment?
The difference is that when a is reassigned the 7 is lost, while it should be still around when shadowed. I don‘t know of a way to access the 7 in this example however.