I've reached a point is my code where it would be tempting to use a go to: label. Labels have always been frowned upon and this makes me hesitate using them.
I want to make it a habit of writing good code and I'm really at an impasse here. On the one hand, there is the convention and on the other the technical drawbacks. I think if there are no technical drawbacks I would go against convention in this case.
How do you pros feel about labels? And are there any technical drawbacks to using jump statements of this kind?
Thanks in advance
Nikos
would you use a jump statement
There are no technical drawbacks. Maybe jumping in and out of scopes can have effects on automatic objects. The drawback with jump statements is that they make it more difficult to follow the flow of control, adding a risk for something going wrong.
Usually, when resorting to using a "goto", it is an indication that the flow of logic has become too entangled. That is the real problem.
See some interesting thoughts at Goto Considered Harmful. I should add that this is a discussion that can easily turn into a flame war. But most people probably agree that you should avoid goto as much as possible.
Usually, when resorting to using a "goto", it is an indication that the flow of logic has become too entangled. That is the real problem.
See some interesting thoughts at Goto Considered Harmful. I should add that this is a discussion that can easily turn into a flame war. But most people probably agree that you should avoid goto as much as possible.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement