Questions tagged [goto]
The goto tag has no usage guidance.
15
questions
47
votes
12
answers
20k
views
Avoiding the goto voodoo?
I have a switch structure that has several cases to handle. The switch operates over an enum which poses the issue of duplicate code through combined values:
// All possible combinations of One - ...
10
votes
7
answers
9k
views
Best practice to "continue" from inside a nested loop?
Here is a simplified sample. Basically, it does checks on a string from a string list. If the check passes, it will remove that string (filterStringOut(i);), and it is no longer ...
-1
votes
3
answers
377
views
I just used a goto statement. Is this OK? [closed]
I just wrote this code that uses a goto statement.
if (PyMethod_Check(attrib_value)) {
PyObject *im_self = PyObject_GetAttrString(attrib_value, "im_self");
if (im_self == Py_None) {
...
-1
votes
2
answers
443
views
Single exit of function uses goto
Apropos of What kind of bugs do "goto" statements lead to? Are there any historically significant examples?
I am not that learned in C, and to me the puzzle is that a single exit of a ...
107
votes
11
answers
20k
views
What kind of bugs do "goto" statements lead to? Are there any historically significant examples?
I understand that save for breaking out of loops nested in loops; the goto statement is evaded and reviled as a bug prone style of programming, to never be used.
Alt Text: "Neal Stephenson thinks it'...
41
votes
10
answers
16k
views
What is so bad with goto when it's used for these obvious and relevant cases?
I have always known that goto is something bad, locked in a basement somewhere never to be seen for good but I ran into a code example today that makes perfect sense to use goto.
I have an IP where I ...
2
votes
3
answers
4k
views
Can you pass a label as an argument, and have the function return to it?
So I would like to be able to call a function like this:
void func(1, 2, 3, (void*)label) // can return normal or to the labels
//some code
label:
//different code
Is it possible, and is it bad ...
0
votes
3
answers
704
views
Are there languages that allow goto statement to only go down?
goto statements can sometimes be useful to go down (to lower lines of code) in code, but can create a mess if used to go up (to higher lines of code). Therefore, I am wondering if there is any ...
1
vote
2
answers
356
views
Is goto to improve DRY-ness OK? [duplicate]
My code has many checks to detect errors in various cases (many conditions would result in the same error), inside a function returning an error struct. Instead of looking like this:
err_struct ...
15
votes
7
answers
2k
views
Does this justify goto statements?
I came across this question a second ago, and I'm pulling some of the material off of there: Is there a name for the 'break n' construct?
This appears to be a needlessly complex way for ...
8
votes
3
answers
3k
views
Why was GOTO included in PHP 5? [closed]
I discovered some time ago that the GOTO control keyword was introduced in PHP 5.3.0.
http://php.net/manual/en/control-structures.goto.php
Why did it happen?
What are the language design goals ...
65
votes
12
answers
33k
views
Is this a decent use-case for goto in C?
I really hesitate to ask this, because I don't want to "solicit debate, arguments, polling, or extended discussion" but I'm new to C and want to gain more insight into common patterns used in the ...
0
votes
6
answers
2k
views
Syntax for goto labels
In C, C++ and some dialects of BASIC, goto labels are declared with the syntax label:. I'm working on a language that uses name: type as the syntax for variable declarations, so I'd prefer if possible ...
31
votes
10
answers
17k
views
Do we still have a case against the goto statement? [duplicate]
Possible Duplicate:
Is it ever worthwhile using goto?
In a recent article, Andrew Koenig writes:
When asked why goto statements are harmful, most programmers will say something like "because ...
32
votes
14
answers
26k
views
Is using goto ever worthwhile?
goto is almost universally discouraged. Is using this statement ever worthwhile?