Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interestingly, many seem to want to project their own opinion upon Dijkstra.

Dijkstra is clearly arguing for a “single entry single exit” style. But modern consensus seem to uphold single entry but accept multiple exits from a block. Break, continue, early returns, exceptions - all are example of multiple exit. These are more constrained than gotos but nevertheless Dijkstras argument applies to them also.

I personally belive early returns can greatly improve readability (when not nested too deep) an that exceptions are typically cleaner than the alternative. But I acknowlede Dijkstra would disagree.



IIRC multiple entry points were common in Dijkstra's times.

Break, continue, and early returns always return to the end of the block, unlike goto in the '70s. Exceptions are more complicated, and the cause of a lot of inunderstandable programs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: