4 ms·
The 'hidden gotos', especially like an early return, for me have stricter guarantees and limitations than a goto used in the same way. Goto and labels can do to
by ketzu 4y ago
The 'hidden gotos', especially like an early return, for me have stricter guarantees and limitations than a goto used in the same way. Goto and labels can do too much for me to like them, i prefer more specific things with clearer boundaries and intent.
- andi999 4y agoWhat are these guarantees? One is that they are easier to miss when reading the code.
- ketzu 4y agoSorry, I don't fully understand what you mean by that. Are "early returns" easier to miss when reading code (easier to miss than goto statements achieving the same effect)? If that was your intended meaning (sorry I am missing some sleep today) I don't share that view, I think both statements are equally obvious in that regard. Examples I was thinking about: * an early return can only go back to the call-site * all returns in a function or method return to the same place * an early return terminates the context it is in * an early return does not create an entry point for nearly arbitrary other code points as labels for gotos do