+ 2
Why goto statement is illegal in high level languages? That the reason it's only use in C language.
Answer the simple question https://www.sololearn.com/discuss/1748622/?ref=app https://www.sololearn.com/discuss/1747406/?ref=app https://www.sololearn.com/discuss/1747250/?ref=app https://www.sololearn.com/discuss/1747987/?ref=app https://www.sololearn.com/discuss/1748869/?ref=app https://www.sololearn.com/discuss/1748463/?ref=app https://www.sololearn.com/discuss/1747987/?ref=app
4 Respostas
+ 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
+ 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.
+ 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.
+ 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.