| | |
goto statements
![]() |
•
•
Join Date: Jul 2005
Posts: 164
Reputation:
Solved Threads: 5
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.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
>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.
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.
I'm here to prove you wrong.
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.
>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.
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.
I'm here to prove you wrong.
![]() |
Similar Threads
- Help (C++)
Other Threads in the C Forum
- Previous Thread: zenos series
- Next Thread: Heap sort, a little help
| Thread Tools | Search this Thread |
#include * adobe ansi array asterisks bash binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer license linked linkedlist linux list locate looping lowest matrix meter microsoft number oddnumber opendocumentformat openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing scripting segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






