| ▲ | Zambyte 3 hours ago | |
Probably closer to defer in Zig than in Go, I would imagine. Defer in Go executes when the function deferred within returns; defer in Zig executes when the scope deferred within exits. | ||
| ▲ | rwmj 24 minutes ago | parent [-] | |
This is the crucial difference. Scope-based is much better. By the way, GCC and Clang have attribute((cleanup)) (which is the same, scope-based clean-up) and have done for over a decade, and this is widely used in open source projects now. | ||