3 ms·
What is the problem of this goto use in particular, except that you don’t like see goto?
by up2isomorphism 3y ago
What is the problem of this goto use in particular, except that you don’t like see goto?
- quietbritishjim 3y agoThis is a classic low-effort comment that requires a high-effort response. Still, I've finally caved in and written one. It's like asking why do you not like driving this car in particular while it's on fire? Disliking a use of goto does not need individual justification. All the usual reasons apply, from all the way back to the 1970s when structured programming was introduced. (Although, back then, goto could jump into totally different functions so was enormously worse.) And I already said that, in this case in particular, refactoring to avoid it would improve the code clarity. The goto I referenced in particular was to re-attempt formatting after an initial attempt did not finish within some limits. But the core element that is attempted twice could be put in its own function and simply called (up to) twice in the outer function. This would make things clearer by itself, but in addition it also means the many local variables (also a bad sign) could be split across the two functions. More importantly – and I think this implication was always clear – this is such a fundamental and easily avoided mistake that it reflects worryingly on the developer writing the code. In short, this function is not writen by someone whose code I would want any production software to depend upon.