|
|
|
|
|
by zokier
3614 days ago
|
|
Resource wouldn't necessary be something internal in the application, it could be also some external system or something like that. You might want to close TCP connections cleanly in destructors, or maybe more relevantly for embedded systems the resource might be some actual physical gadget that is activated/deactivated. Of course this is all hypotheticals and it could very well be argued that relying on destructors to do something actually critical would be a bad design. |
|
Eh, I'd only argue that in the case of garbage collected languages. In RAII languages like Rust and C++, it's the preferred way.