944,144 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2597
  • C RSS
Oct 4th, 2005
0

goto statements

Expand Post »
can any one highlight the overheads in goto statement
Similar Threads
SpS
Reputation Points: 70
Solved Threads: 32
Posting Pro
SpS is offline Offline
598 posts
since Aug 2005
Oct 4th, 2005
0

Re: goto statements

biggest overheads with goto is having your peers laugh at you.Also a goto in a function will make life hard for the optimiser to do its job properly so your function may go unoptimised. It is not particularly dangerous to use but it does have a habit of making code hard to follow. I only ever use it to break out of deeply nested loops where a break statement just wont do and an extra variable with comparisons would be too much overhead or complication. This is probably the only acceptable use for goto and even then most will go with the extra variable solution. In several places where Ive worked a goto is enough to violate the coding standard.
Reputation Points: 19
Solved Threads: 5
Junior Poster
Stoned_coder is offline Offline
164 posts
since Jul 2005
Oct 4th, 2005
0

Re: goto statements

I have heard gotos are really vln, I wouldn't use them.
but if you must know:

start:
blah blah statments
goto start;

i think.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
The_Inferno is offline Offline
10 posts
since Sep 2005
Oct 5th, 2005
0

Re: goto statements

Dont use them... i did once in a program and lost beaucoups of points... so i dont recommend it.
Reputation Points: 10
Solved Threads: 3
Junior Poster
jhdobbins is offline Offline
105 posts
since Apr 2005
Oct 5th, 2005
0

Re: goto statements

Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Oct 5th, 2005
0

Re: goto statements

>biggest overheads with goto is having your peers laugh at you.
Amen. Of course, I would say that the biggest overhead at first is constantly having to defend your decision to use a goto. Even if you use it intelligently, there are armies of the ignorant waiting to flame you for it because "goto is evil".

But it gets worse. The more your peers respect you, the less they'll try to second guess your decisions and the more they'll try to emulate you. Therein lies the danger of goto because even if you know how to use it, and when to use it, a bunch of people who hear how "Narue's code is awesome" and see how that "awesome code" used goto will probably use it too, but not in the right way.

Of course, that still doesn't stop me from using goto when I feel the need, even if I don't feel the need often.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Oct 6th, 2005
0

Re: goto statements

my company forbids use of goto, and it is strictly enforced during peer review. Yes, programmers are NOT free to just code any way they wish -- there are coding standards and the code is periodically reviewed to insure those standards are followed. There is absolutely never justification for its (goto) use.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Oct 6th, 2005
0

Re: goto statements

>my company forbids use of goto, and it is strictly enforced during peer review.
I'm lucky enough that my company trusts its programmers to know what they're doing. We enforce good code through the senior programmers teaching and setting a good example, and it works amazingly well. Naturally there are coding standards, but they're far more lenient than most places and meant primarily for consistency between modules. Still, you're unlikely to find any code with a goto.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: zenos series
Next Thread in C Forum Timeline: Heap sort, a little help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC