Funny, I’v got more or less similar thoughts/feeling about RAII. Externally it looks just like this - a lot of hard mental work done by a language/compiler designers, but for what? Just to let lazy/capricious/beginner/forgetful programmers omit cleanup code? Is it really THAAAT hard to write cleanup code explicitly? In C I’m quite happy with goto __cleanup
way, In Zig we have defer/errdefer
. The latter a bit harder to grasp imo, but we have some sensible rules.
2 Likes