0 like 0 dislike
asked in Computer Science by (474k points)
What is the purpose of goto statement?

1 Answer

0 like 0 dislike
answered by (474k points)
The “goto” statement is one of the very essential commands in every language. It just tells the program to jump to a label, a different part of the program and commence the execution there.

It is like a function, like a call just that you don’t expect the execution to return to the original place.

The “goto” as a command was getting a lot of shit over the years but most people have learned by now, after all the “Goto considered harmful” hype of the late 60’s, that this command is essential and important and that you can’t do without it.

There are many examples, like the implementation of state machines, that is essential the goto, while I would argue it is the “on X goto A, B, C”, but that’s an other thing that’s missing in most modern languages.

Language designers were trying to get rid of it, with the result that most languages came to senses and reimplemented it.

For example Lua 5.2 did so after trying 25 years without it. And with that LuaJIT did.
Welcome to Free Homework Help, where you can ask questions and receive answers from other members of the community. Anybody can ask a question. Anybody can answer. The best answers are voted up and rise to the top. Join them; it only takes a minute:

10.2k questions

9.2k answers


3.2k users


Free Hit Counters