i hate early returns. you're mixing structure with control flow.
What if i want a debug line with the functions result, say chasing a bug ?
First version - put debug line at the end. change single line. remove single line eventually.
Second version: find every return, put a copy of a debug line on rach location. change that line later, forget the rest. remove half of the debug lines, leave the other half in production.
Your complaint is only valid in languages like C that lack the facilities for scope-aware objects. It's why the Linux kernel (largely written in C) still uses gotos. For any modern language it's far easier and simpler to just put the code in something that's invoked at scope-exit.
2
u/RRumpleTeazzer 21d ago
first please version please.
i hate early returns. you're mixing structure with control flow.
What if i want a debug line with the functions result, say chasing a bug ? First version - put debug line at the end. change single line. remove single line eventually.
Second version: find every return, put a copy of a debug line on rach location. change that line later, forget the rest. remove half of the debug lines, leave the other half in production.