About whether the goto statement can be jumped out of the complicated nested loop

Source: Internet
Author: User
Regarding the use of the goto statement, it is difficult to use it technically. When I write this text about the use of the goto statement, I think it is difficult for beginners to grasp it if the goto is in another position from a complicated execution state. In a multi-nested loop judgment, the number of program execution paths is very large. After jumping out with the goto statement, it is difficult for beginners to find out if there are any problems with those paths. From another perspective, if you allow a goto statement to jump out of Multi-nested loop judgment, you are encouraged to use the goto statement. This is not a problem for experienced users, however, it is prone to abuse for beginners. It does not matter if you do not use the goto statement. However, once the goto statement is used in a large scale, the consequences will be greater. A few years ago I found many goto statements in one of my subordinate codes. I said, "Isn't the goto statement not recommended? Why are so many goto statements in your code ?" He told me that the goto statement can be used in other books. Therefore, we have made repeated trade-offs. In order to avoid abuse of the goto statement and to avoid bringing beginners astray, I still wrote the words that the goto statement cannot jump from a complicated state to another place. I have some opinions on the goto statement above. If this is not the case, please correct me.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.