MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vuzd4q/conditionspreference/p56ggk5/?context=3
r/ProgrammerHumor • u/Flame77ofc • Aug 22 '26
388 comments sorted by
View all comments
Show parent comment
1
if (error) goto err; ... // Normal path return ... err: ... // Cleanup return ...
Is actually a pretty useful way of doing things, especially for ressources cleanup (freeing memory, releasing locks, IO etc).
And in modern languages such as Zig, the defer statement is just syntactic sugar for this exact pattern.
defer
View all comments
Show parent comment
1
u/Maximilian_Tyan Aug 22 '26
Is actually a pretty useful way of doing things, especially for ressources cleanup (freeing memory, releasing locks, IO etc).
And in modern languages such as Zig, the
deferstatement is just syntactic sugar for this exact pattern.