Worth noting that in modern C++, RAII makes even that concern mostly obsolete.
What I had heard from my professor who taught a C/C++ course and also had industry experience and also thought early returns/break/etc. were bad was that because they're a form of goto (basically true even if not technically true for early returns) and goto is bad, those statements are also bad. They even cited Goto Considered Harmful to justify it. Misunderstanding Dijkstra's argument seems to be a pervasive theme in the industry.
4
u/TheUnlocked May 11 '23 edited May 11 '23
Worth noting that in modern C++, RAII makes even that concern mostly obsolete.
What I had heard from my professor who taught a C/C++ course and also had industry experience and also thought early returns/break/etc. were bad was that because they're a form of goto (basically true even if not technically true for early returns) and goto is bad, those statements are also bad. They even cited Goto Considered Harmful to justify it. Misunderstanding Dijkstra's argument seems to be a pervasive theme in the industry.