total = [42, 13, 57] # it's a bird, er uh list total = sum # it's a plane, er uh int total = f'{sum'} # it's a supervar!, er uh str
And when I talk to functionary zealots, they like to point out that assigning a variable to different values (even of the same type) violates everything we learned in school about math.
x = 57 - 42 x = 13 # but wait, I thought x was 14. I'm so confused now
Given these sentiments, why do the cadre of mainstream popular languages embrace Variable shadowing (https://en.wikipedia.org/wiki/Variable_shadowing)?
I would have thought that as computer languages became more interested in "correctness", that this loophole for cognitive confusion (and even unexpected behavior/bugs) would be discouraged or even disallowed.