top | item 47088046 (no title) feelamee | 9 days ago if you do it once - why do you care about "ugly" scope_exit? btw, writing such wrappers is easy and does not require a lot of code. discuss order hn newest mort96|9 days ago What do you mean with '"ugly" scope_exit'?Do you mean why I care that I have to call the free function at every exit point of the scope? That's easy: because it's error prone. Defer is much less error prone. feelamee|8 days ago your words... > C++ implementations of defer are either really uglyI agree with @pjmlp - you need to write wrappers around the C api.But if you.. > If I'm gonna write RAII wrappers around every tiny little thing that I happen to need to call onceuse them just once.. so, why care about ugliness, just write ugly code just once? Code can't be perfect.
mort96|9 days ago What do you mean with '"ugly" scope_exit'?Do you mean why I care that I have to call the free function at every exit point of the scope? That's easy: because it's error prone. Defer is much less error prone. feelamee|8 days ago your words... > C++ implementations of defer are either really uglyI agree with @pjmlp - you need to write wrappers around the C api.But if you.. > If I'm gonna write RAII wrappers around every tiny little thing that I happen to need to call onceuse them just once.. so, why care about ugliness, just write ugly code just once? Code can't be perfect.
feelamee|8 days ago your words... > C++ implementations of defer are either really uglyI agree with @pjmlp - you need to write wrappers around the C api.But if you.. > If I'm gonna write RAII wrappers around every tiny little thing that I happen to need to call onceuse them just once.. so, why care about ugliness, just write ugly code just once? Code can't be perfect.
mort96|9 days ago
Do you mean why I care that I have to call the free function at every exit point of the scope? That's easy: because it's error prone. Defer is much less error prone.
feelamee|8 days ago
I agree with @pjmlp - you need to write wrappers around the C api.
But if you.. > If I'm gonna write RAII wrappers around every tiny little thing that I happen to need to call once
use them just once.. so, why care about ugliness, just write ugly code just once? Code can't be perfect.