3 ms·
Scoping defer to a block is actually more useful and explicit than function-exclusive that Go does, so I consider that a feature.
by aartaka 2y ago
Scoping defer to a block is actually more useful and explicit than function-exclusive that Go does, so I consider that a feature.
- w4rh4wk5 2y agoNo no, I think you misunderstood my critic. Defer working on block-scope is fine; however, if I exit the block through a return (or break), the deferred function is not called. To my knowledge, you need a compiler extension to implement this in C (or use a C++ destructor).