3 ms·
> defers are function-scoped instead of block-scoped. I think this is a basic tradeoff with defer and not a problem per se. Are users more likely to need to cl
by oconnor663 2y ago
> defers are function-scoped instead of block-scoped.
I think this is a basic tradeoff with defer and not a problem per se. Are users more likely to need to clean up resources every time through a loop, or more likely to acquire resources that outlive the loop? And which is more confusing if you expected the other? I think it's a tough call. (I understand why a systems programming language would insist on block scoping to avoid allocating.)