Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by fauigerzigerk on Friday July 16, 2021 @05:36AM
(#27854524)
>It may not fit your mental model...
No, it's not a psychological problem. This is real complexity, and it's one of the most serious and widespread issues in software development.
The key issue is that we often have rules that say: Whenever A happens then B must happen as well. It is absolutely critical that rules like this are expressed in exactly one place and that enforcement is opt-out not opt-in.
Everything else is error prone and creates significant mental burden.
Instead you'd return an object, and make it the callers responsibility to close it. Destruct all three in the close call.
It may not fit your mental model, and that's fine. But let's not pretend it's a serious hurdle.