3 ms·
But with defer you can easily get the order of things wrong, whereas destructors are automatically called in the correct order.
by gsliepen 5y ago
But with defer you can easily get the order of things wrong, whereas destructors are automatically called in the correct order.
- watt 5y agoThe advantage of "defer" is that it's explicit. It's right there, and it's crystal clear when it will run. The "implicitness" and hidden nature of destructors is a disadvantage, it's the unpleasant way it can introduce behavior which might be surprising.