Difference between revisions of "Goto"
Karl Jones (Talk | contribs) (→See also) |
Karl Jones (Talk | contribs) |
||
Line 1: | Line 1: | ||
− | '''Goto''' ('''goto''', '''GOTO''', '''GO TO''' or other case combinations, depending on the programming language) is a [[Statement (computer science)|statement]] found in many computer [[Programming language|programming languages]]. | + | '''Goto''' ('''goto''', '''GOTO''', '''GO TO''' or other case combinations, depending on the [[programming language]]) is a [[Statement (computer science)|statement]] found in many computer [[Programming language|programming languages]]. |
== Description == | == Description == | ||
Line 5: | Line 5: | ||
It performs a one-way transfer of control to another line of code; in contrast a function call normally returns control. | It performs a one-way transfer of control to another line of code; in contrast a function call normally returns control. | ||
− | The jumped-to locations are usually identified using labels, though some languages use line numbers. | + | The jumped-to locations are usually identified using [[Label (computer science)|labels]], though some languages use line numbers. |
At the machine code level, a goto is a form of branch or jump statement. | At the machine code level, a goto is a form of branch or jump statement. | ||
Line 28: | Line 28: | ||
* [[Go To Statement Considered Harmful]] | * [[Go To Statement Considered Harmful]] | ||
+ | * [[Label (computer science)]] | ||
* [[Spaghetti code]] | * [[Spaghetti code]] | ||
* [[Statement (computer science)]] | * [[Statement (computer science)]] | ||
Line 40: | Line 41: | ||
* [https://en.wikipedia.org/wiki/Goto Goto] @ Wikipedia | * [https://en.wikipedia.org/wiki/Goto Goto] @ Wikipedia | ||
+ | |||
+ | |||
+ | [[Category:Computer programming]] | ||
+ | [[Category:Software engineering]] |
Revision as of 11:03, 28 April 2016
Goto (goto, GOTO, GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages.
Description
It performs a one-way transfer of control to another line of code; in contrast a function call normally returns control.
The jumped-to locations are usually identified using labels, though some languages use line numbers.
At the machine code level, a goto is a form of branch or jump statement.
Many languages support the goto statement, and many do not (see language support).
The structured program theorem proved that the goto statement is not necessary to write programs; some combination of the three programming constructs of sequence, selection/choice, and repetition/iteration are sufficient for any computation that can be performed by a Turing machine, with the caveat that code duplication and additional variables may need to be introduced.
At machine code level, goto is used to implement the structured programming constructs.
In the past there was considerable debate in academia and industry on the merits of the use of goto statements.
Use of goto was formerly common, but since the advent of structured programming in the 1960s and 1970s its use has declined significantly.
The primary criticism is that code that uses goto statements is harder to understand than alternative constructions.
Goto remains in use in certain common usage patterns, but alternatives are generally used if available.
Debates over its (more limited) uses continue in academia and software industry circles.
See also
- Go To Statement Considered Harmful
- Label (computer science)
- Spaghetti code
- Statement (computer science)
- Structured programming
External links
- Goto @ Wikipedia