4 Réponses
+ 5
even in C, goto are not recommended to be use, several books I have read it's hard to find a part where goto is been explain/explain in details, the reason been that it makes code hard to debug, and there are been replaced using loops, or recursive functions, which I think are better and easy to debug please remove all other post if they are not related to your questions, I hope the answer given above satisfy your question
6th Apr 2019, 7:22 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
Goto is also used in Basic. Usually there is a Gosub as well. Consider the Gosub like a function and Goto a separate layer of a program. Gosub has a Return to end the subroutine that will take the program back to the line after it was called. Goto is more permanent, however you could try to track where the Goto originally came from and use Goto to send the execution back to the point of origin, but that is not the best way to branch out and get back. I imagine that the Goto in C works just like its counterpart in Basic. I also think that readability is a factor in why the use of Goto is a discouraged practice.
6th Apr 2019, 11:43 AM
Michael Williams
Michael Williams - avatar
+ 1
Goto statement is discouraged because it enables unconditional branching and alters the natural flow of code which makes it confusing and hence hard to debug in case of any exception occurred.
13th Apr 2019, 3:12 AM
Noopur
Noopur - avatar
+ 1
You would get a confusing code also called spaghetti code. Just think of a bunch of arrows pointing in different directions. And then throw them together like Mikado sticks. Would look like a maze.
14th Apr 2019, 4:22 PM
Mathias Baum
Mathias Baum - avatar