Jump to content
  • Advertisement
Sign in to follow this  
heron3d

would you use a jump statement

This topic is 2170 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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. Edited by larspensjo

Share this post


Link to post
Share on other sites

See some interesting thoughts at Goto Considered Harmful.

That is funny. His guidelines apply in my case. My goto will point forward and will make my code incredibly more easy to understand and it is only used once.

I've decided. thanks. gamedev.net rocks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!