3 ms·
Defer has to be added manually and maintained correctly, and often has double call challenges and so on. Automatic behavior on scope exit is less fallible (incl
by raggi 3y ago
Defer has to be added manually and maintained correctly, and often has double call challenges and so on. Automatic behavior on scope exit is less fallible (including e.g. it can’t just be broken by the machine in a pathological patch application), and has fewer logical pathologies such as double execution cases. Defer was re-popularized by go, but I think rooted in a knee jerk from bad c++. The scope mechanisms are better, as discussed and it’d be great to see them in more places.