2 ms·
I very much enjoyed the discussion, I'm sorry if it got heated. In any case, I think single-exit is fine for a corporation that needs to use clearly-defined, e
by Goladus 19y ago
I very much enjoyed the discussion, I'm sorry if it got heated. In any case, I think single-exit is fine for a corporation that needs to use clearly-defined, easy-to-follow policies. It's a reasonable baseline.
However, there are cases where trying to workaround multiple exits does lead to more errors. A function that returns 'right' 'left' or 'both' is probably better off having 3 returns rather than assigning the result to a local variable and carrying it to the end of the function. You might declare the local as the wrong type, you might forget an 'else' and accidentally overwrite the return value, etc. "No early exits unless your function has no side-effects" is a lot less clear to most programmers.
Of those 495 bugs on the bug list, how many were caused by broken side-effects?
- edw519 19y agoNo need for anyone to apologize. We should all have pretty thick skin here. My only regret: I took a 5 minute break and posted a top 10 list for a few chuckles. I ended up spending 2 hours here and didn't finish my day's work until after midnight. Pretty soon I may need a 12 Step program for news.ycombinator.com.
- nostrademons 19y agoThere's noprocrast. Lifesaver (well, timesaver) for me...
- edw519 19y agoNo need for that. I can handle it. Sure, I can. Really, I can.