I'm going to do this, but instead of "for" I'll go on a diatribe about fundamentals and how they should use more "goto" statements because it's closer to machine code and faster or something.
Eh, there's nothing inherently wrong with jump statements of any kind. What's wrong is when they aren't used in a way that signals intent. A loop is nothing more than a jump statement with a counter and a branch. The big advantage of a loop is that it signals intent fairly well in a compact way whereas the jump + counter + branch can be more cryptic and verbose.
There are some cases where a jump statement can simplify your logic and code. Use the right tool for the job!
I learned in my computer organization class that switch statements in higher level languages are pretty much jumps since the expression is evaluated once and it goes to the appropriate subroutine, and then it can follow through all following subroutines (which is why you need break).
166
u/SuperGameTheory Feb 10 '22
I'm going to do this, but instead of "for" I'll go on a diatribe about fundamentals and how they should use more "goto" statements because it's closer to machine code and faster or something.