In imperative programming, a "go to" statement is an unconditional jump instruction that changes the flow of control to the point of the program referenced by the "go to" statement.
Questions tagged [goto]
1057 questions
12
votes
4 answers
Jump command in MATLAB
I'm working with the m-file editor of MATLAB and I need to jump from one line to another.
If I need to jump from inside a For...end, I can't use the usual "while"
technique.
Is there anyway to jump from a line to another, like goto in C?
Arash
11
votes
3 answers
Bash - writing function definition in script after first call (as a GOTO/jump problematics)
I basically want to write me a bash script, where I'd generate a couple of big files using heredoc; and then run some commands using those files.
It is understood that (obviously) the heredoc files need to be generated before the commands run -…

sdaau
- 36,975
- 46
- 198
- 278
11
votes
2 answers
Actually CATCHing exceptions without creating GOTO
Looking over my Raku code, I've realized that I pretty much never use CATCH blocks to actually catch/handle error. Instead, I handle errors with try blocks and testing for undefined values; the only thing I use CATCH blocks for is to log errors…

codesections
- 8,900
- 16
- 50
11
votes
1 answer
Can `goto LABEL` cause a memory leak?
Can using goto with labels cause memory leaks? All I found in the documentation for goto that seems relevant is:
The goto LABEL form finds the statement labeled with LABEL and resumes execution there.
Is it safe to use goto LABEL?

yoniyes
- 1,000
- 11
- 23
11
votes
11 answers
Difference between GOTO and THROW?
Many people accused me recently for just mentioning a single word - "goto".
It makes me wonder, why it is considered such a nasty word.
I am aware of several previous discussions on the topic, but it doesn't convince me - some of the answers just…

Your Common Sense
- 156,878
- 40
- 214
- 345
11
votes
2 answers
Bad practice to use SQL Server's GOTO for error handling?
I was reading about error handling in SQL Server in this article, and they suggest using SQL Server's GOTO in certain situations to roll back the transaction. Example:
BEGIN TRAN
UPDATE Authors
SET Phone = '415 354-9866'
WHERE au_id =…

Abe Miessler
- 82,532
- 99
- 305
- 486
10
votes
4 answers
Goto before variable initialization causes compiler error
Consider this code (VS2008):
void WordManager::formatWords(std::string const& document)
{
document_ = document;
unsigned int currentLineNo = 1;
size_t oldEndOfLine = 0;
size_t endOfLine = document_.find('\n');
while(endOfLine…

IAE
- 2,213
- 13
- 37
- 71
10
votes
6 answers
How goto statement works in this example?
I am studying this code sample:
class Program
{
static void Main(string[] args)
{
int x = 10;
int y = 10;
int generate=0;
string [,] myArrayTable = new string[x, y];
Console.WriteLine("Enter a seek…

Mircea
- 3,369
- 6
- 27
- 26
10
votes
10 answers
Is this goto expressive?
The following code was a proof of concept for a message batching routine. Do I avoid goto like the plague and rewrite this code? Or do you think the goto is an expressive way to get this done?
If you'd rewrite please post some code...
var queue =…

jsw
- 1,752
- 1
- 14
- 20
10
votes
2 answers
ipython notebook navigate between cells
is there a way in ipython notebook to navigate between cells which are far apart? For example if I have a large notebook and I want to move from a cell near the top of the notebook and then back to one at the bottom. Can I do this? I was thinking…

user2560444
- 181
- 1
- 2
- 6
10
votes
14 answers
GoTo statements and alternatives in VB.NET
I've posted a code snippet on another forum asking for help and people pointed out to me that using GoTo statements is very bad programming practice. I'm wondering: why is it bad?
What alternatives to GoTo are there to use in VB.NET that would be…

qais
- 113
- 2
- 2
- 6
10
votes
4 answers
use goto inside function php
Is there a way to define global label (something like variables) for PHP goto, in order to use it inside function declaration. I want to do the following:
function myFunction() {
if (condition) {
goto someLine;
}
}
someLine:
//…

dav
- 8,931
- 15
- 76
- 140
10
votes
2 answers
Differences between Coroutines and `goto`?
I always read about the horrible thing that "goto" is. But today, reading about the Google programming language Go, I see that it suports Coroutines (Goroutines).
The question is:
Coroutine == GoTo
Or
Coroutine != GoTo?
Why?

mRt
- 1,223
- 6
- 18
- 32
10
votes
9 answers
Is Erlang's recursive functions not just a goto?
Just to get it straight in my head. Consider this example bit of Erlang code:
test() ->
receive
{From, whatever} ->
%% do something
test();
{From, somethingelse} ->
%% do…

Toad
- 15,593
- 16
- 82
- 128
10
votes
3 answers
GCC computed goto and value of stack pointer
In GCC you can use a computed goto by taking the address of a label (as in void *addr = &&label) and then jumping to it (jump *addr). The GCC manual says you can jump to this address from anywhere in the function, it's only that jumping to it from…

jleahy
- 16,149
- 6
- 47
- 66