Skip to main content

Questions tagged [goto]

47 votes
12 answers
21k views

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 - ...
Taco's user avatar
  • 1,175
13 votes
7 answers
13k views

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 ...
Anon's user avatar
  • 3,649
-1 votes
3 answers
414 views

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) { ...
tbodt's user avatar
  • 115
-1 votes
2 answers
676 views

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 ...
user3824211's user avatar
107 votes
11 answers
22k views

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's ...
Anon's user avatar
  • 3,649
41 votes
10 answers
18k views

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 ...
php_nub_qq's user avatar
  • 2,240
2 votes
3 answers
5k views

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 ...
JavaProphet's user avatar
0 votes
3 answers
800 views

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 ...
Akavall's user avatar
  • 455
1 vote
2 answers
392 views

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 ...
Marco Scannadinari's user avatar
15 votes
7 answers
2k views

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 ...
Panzercrisis's user avatar
  • 3,223
8 votes
3 answers
3k views

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 ...
Tulains Córdova's user avatar
70 votes
12 answers
36k views

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 ...
Robz's user avatar
  • 1,653
0 votes
6 answers
2k views

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 ...
rwallace's user avatar
  • 1,208
32 votes
10 answers
18k views

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 ...
fredoverflow's user avatar
  • 6,954
37 votes
14 answers
32k views

goto is almost universally discouraged. Is using this statement ever worthwhile?
Casebash's user avatar
  • 7,682