ANSWERS: 5
  • The only reason I can see that it is discouraged is that it only CAN cause problems. Subroutines need to be subroutines. Simply put : "Goto" doesn't garuntee a return and can toss errors.
  • It depends. In languages that do not support exception handling, "goto" can be used to redirect program flow into a separate block of code used for error handling.
  • "The GOTO statement has been the target of much criticism, the claim being that use of GOTO produces unreadable and generally unmaintainable "spaghetti code". As structured programming became more popular in the 1960s and 1970s, many computer scientists came to the conclusion that programs should always use so-called 'structured' flow-control commands such as loops and if-then-else statements in place of GOTO. However, others believed that use of GOTO did not unconditionally lead to poor quality code and that there are some tasks that cannot be straightforwardly accomplished in many programming languages without the use of one or more GOTO statements, such as implementing finite state machines, breaking out of nested loops and exception handling." Source and further information: http://en.wikipedia.org/wiki/GOTO#Criticism_of_goto_usage
  • It has always been suugested to not use Goto in our programs, instead use for while and other stuff like it. why?? firstly, using goto may insert labels into the program and when we encounter a label at a particular place in the program, it becomes very difficult to say from where might have the control landed up there. It makes the understanding of the difficult and hence the debugging gets even tougher. secondly, using constructs like for, while makes the program somewhat structured and its easy to trace the flow of control withinn the code... also using these constructs maps the code to real world scenario where a conditional statement may be represented as an decision and a for while may be regarded as repeating sometimes over and over.... but what does Goto represent in real world scenario?? Thirdly, making use of too much Goto may result in speghetti code . There is also a story associated with goto. have a look. ( http://www.acm.org/classics/oct95/ ) For speghetti : http://en.wikipedia.org/wiki/Spaghetti_code
  • As being the beninner of programming we feel easy to use goto rather than using those functions and loop. But we may realize it when it will be difficult to trace the error because goto statement changes the flow of program from one to other . so many programmers avoid using it.

Copyright 2020, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy