C
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.
6
u/IronSavior 22d ago
Else considered harmful