▲ | gf000 4 days ago | |||||||||||||||||||||||||||||||||||||
Making it lexical scope would make both of these solvable, and would be clear for anyone reading it. You can just introduce a new scope wherever you want with {} in sane languages, to control the required behavior as you wish. | ||||||||||||||||||||||||||||||||||||||
▲ | lowmagnet 4 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||
You can start a new scope with `{}` in go. If I have a bunch of temp vars I'll declare the final result outside the braces and then do the work inside. But lately days I'll just write a function. It's clearer and easier to test. | ||||||||||||||||||||||||||||||||||||||
▲ | tgv 4 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||
Currently, you can write
When it's lexically scoped, you'd need to add some variable. Not that that happens a lot, but a lexically scoped defer isnt needed often either. | ||||||||||||||||||||||||||||||||||||||
|