Talk:Goto

Help Here!
Can someone please explain the goto relation to object oriented programing specifically? It seems that it is a compromise between pro and con beliefs on using goto, but that is (my) layman's conjecture. Thanks! — Preceding unsigned comment added by 71.99.3.105 (talk) 23:58, 30 June 2011 (UTC)

Java and Goto
Because of the current popularity of Java, would it be appropriate to discuss the labeled break and labeled continue statements in this article? It has always seemed to me that these constructs, though rarely used, are gotos with restrictions as to where you can "go to". --Eraticus 23:12, 16 April 2007 (UTC)

The Complete Framework for Using Gotos in Java Programs
Does this belong here? Looks like a commercial promotion to me. Any other comments? (Personal POV: I mean apart from the bizzare idea of porting Fortran to Java without rewriting it; this is a joke, right?; the idea that adding jumps to Java would help; the idea that you would actually have something bug free at the end of it; the amazing amount of effort and hacks to get this into Java; why not leave it in fortran? (End personal POV) peterl 03:59, 6 July 2007 (UTC)

Assembly
The article is missing a section on GOTO in assembly language. In assembly (eg PIC ASM), there are no high-level constructs such as for/if-then-else/break etc. There are only: Call/Return, Goto (=Jump) and Conditional Jump (eg the pic's skipz/skipnz). Things such as if-elseif-else are built out of conditional jumps: practically every flow-control structure in assembly is a Goto. --RichardNeill 05:30, 24 July 2007 (UTC)


 * Well, in assembly there is no distinction between goto and non-goto branching. This is a distinction that can only made in higher level languages that have alternatives to "goto". Why would we need to cover "goto in assembly"? It's not even referred to as goto in assembly language. - Rainwarrior 05:51, 24 July 2007 (UTC)

Requested move

 * The following discussion is an archived discussion of the . Please do not modify it. Subsequent comments should be made in a new section on the talk page. No further edits should be made to this section. 

Move. Although the (Fortran) tradition is there, I don't see a compelling reason to override MOS:CAPS; the command is genericized enough in many programming languages. See also Category:Control flow.


 * GOTO → Goto —(Discuss)— This is clearly the primary topic for Goto, and the computer-language usage is not especially capitalized. It should be named in normal case as other programming statements are. Please note that the talk page is currently at Talk:Goto (command) and also needs to be moved. —The way, the truth, and the light 00:34, 7 October 2007 (UTC)


 * Strong Oppose - Just because a few modern languages are case sensitive doesn't mean that the article should default to that usage, contrary to a wider and historical usage. Instead Goto should redirect to GOTO. Note also that the command is capitalised throughout the article. And GOTO is about the command. goto is not. - jc37 09:23, 7 October 2007 (UTC)


 * I did make that redirect. I am not arguing for case-sensitivity - rather, the title should not be, and therefore should use normal Wikipedia conventions to prefer lowercase. The former title of this page, Goto (command), is lowercase. Goto and GOTO simply mean the same thing. The way, the truth, and the light 22:52, 7 October 2007 (UTC)
 * No they aren't necessarily the same, per the wiktionary links I listed above. - jc37 20:27, 12 October 2007 (UTC)


 * Support - Wikipedia conventions dictate that article titles be title case. LordAmeth 07:24, 9 October 2007 (UTC)


 * Support. Per MOS:CAPS.  Re article body, wouldn't  be appropriate formatting for "goto"? ENeville 16:03, 12 October 2007 (UTC)


 * Comment - In reading over the pages, neither the MoS, nor "caps" list an example which apply to this. (Please take a moment and read the pages that you're linking to.) It's a command in programming languages (Assembly language, for example). See x86 instruction listings for examples of commands in upper case. - jc37 20:27, 12 October 2007 (UTC)
 * The above discussion is preserved as an archive of the . Please do not modify it. Subsequent comments should be made in a new section on this talk page. No further edits should be made to this section.

NPOV mark on critcism section
The criticism section had been marked with NPOV. But no explanation was given. The section is well referenced, and the fact that is is criticism doesn't make it POV. Please explain if you want to add that marker back in. peterl (talk) 04:19, 29 January 2008 (UTC)
 * I don't think the NPOV tag was warranted either, but the writing was a bit awkward and did have a weasel word tag. I've tried rewriting several of the sentences to try to make it better. - Dmeranda (talk) 09:44, 29 January 2008 (UTC)

A working GOTO for Python
It was written as an April fool's joke, it works and includes a "comefrom" statement, but there is REALLY no need for it in the language ;)

http://entrian.com/goto/

A working GOTO for Java
An open-source licensed project called JavaGoto. Maybe it has some usefulness in teaching (what GOTO is and why not to use it). https://github.com/footloosejava/JavaGoto — Preceding unsigned comment added by 174.7.38.170 (talk) 04:22, 18 April 2014 (UTC)

It's GO TO in COBOL
Since there seems to be much ado over GOTO vs GoTo, goto, gOTo, etc., it must be important, so I think there should be some mention of the COBOL form being two words. Georget99 (talk) 20:14, 10 April 2009 (UTC)
 * That's not the only occurrence of GO TO. Commodore BASIC accepts both forms: GOTO is tokenized as 0x89; GO TO is tokenized as 0xCB 0xA4. Both forms are interpreted in exactly the same way. Devil Master (talk) 20:41, 28 July 2009 (UTC)

Linus Torvalds
Why on earth are we citing Linux Torvalds as an authority on this particular aspect of computer science? I've removed an extensive verbatim quote of an email he supposedly once sent to the kerneltrap mailing list (!). --TS 18:41, 11 December 2009 (UTC)


 * Linus is a experienced programmer, widely recognised in the computer sciences (NOTABILITY) - please check the wiki article on him for details. He IS an authority when it comes to programming, both C and machine code~, same can be said about his posts on kerneltrap. Also, his views represent a unorthodox stance vs goto usage, contrasting with what most "wannabe specialists" want to believe; representing every important view on the subject, regardless of Your personal preferences, was one of the main Wikipedia ideas. Either edit the form of the article or accept what's fact. DON'T DELETE just because you don't understand it, monopolizing an article is an extreme example of bad taste. Vaxquis (talk) 15:51, 30 January 2010 (UTC)
 * Torvalds is an experienced programmer, certainly, but you still don't explain why his opinion belongs in this article. He's an operating system kernel developer, not a language designer.  Why is his opinion (which is tucked away in some posting on the Linux Kernel Mailing List) in this article?  The mere fact that he has an opinion does not explain that.  The mere fact that he has written operating system kernel code in C does not explain that.  Can you explain that?  --TS 17:03, 30 January 2010 (UTC)
 * because he's not a *theoretician*, but a notable programmer dealing with practical aspects of code creation. drawing the proper line between theory and practice in IT is obviously important, and he clearly shows the point that was clearly visible in older revisions of the page, dating up to 2001 (http://en.wikipedia.org/w/index.php?title=Goto&oldid=255242) - that gotos may be and often are a reasonable choice in programming. feel free to replace Torvalds' quote with any other *well known software designer's* or *notable programmer's* quote, stating what Torvalds said with as little words and so much precision as he did - i won't object to this, the choice of Linus (*not* Linux - you've made a typo there, mate) was made a priori, just because he fits perfectly for a person to state the unobvious obviousness of the usefulness and harmlessness of gotos... i'd say even more - throw out the quote if you feel that it doesn't clarify the point of the preceding statement; but AFAIR wikipedia is not encyclopedia - if we feel that Linus point of view on programming is unimportant just because he hasn't won the Turing Award, we may as well ditch Bill Gates and Eric S. Raymond's opinions on CS & IT for being worthless because the haven't the Neumann Medal. but, if you still insist:
 * In 1997 he received his Master degree (Laudatur Grade) from Department of Computer Science, University of Helsinki.
 * In 1998 he received an EFF Pioneer Award.[24]
 * In 1999 he received honorary doctor status at Stockholm University.
 * In 2000 he received honorary doctor status at University of Helsinki.[25]
 * In 2000 he was awarded the Lovelace Medal.[26]
 * In the Time magazine's Person of the Century Poll, Torvalds was voted at #17 at the poll's close in 2000.[27]
 * In 2001, he shared the Takeda Award for Social/Economic Well-Being with Richard Stallman and Ken Sakamura.
 * In 2004, he was named one of the most influential people in the world by the Time magazine article "Linus Torvalds: The Free-Software Champion" by Lawrence Lessig[28]
 * In the search for the 100 Greatest Finns of all time, voted in the summer of 2004, Torvalds placed 16th.
 * In August 2005, Torvalds received the Vollum Award from Reed College.[30]
 * In 2006, Time Magazine—Europe Edition named him one of the revolutionary heroes of the past 60 years.[32]
 * In 2008, he was inducted into the Hall of Fellows of the Computer History Museum in Mountain View, California.[33][34]


 * please do some research on these awards... Linus Torvalds simply IS somebody notable enough in CS for his opinions to matter. is that enough to meet your nota' criteria or should i search for more? Vaxquis (talk) 22:23, 30 January 2010 (UTC)


 * I don't think you need to use sarcasm, and in reference to your latest edit summary on this page, of course I'm prepared to wait for a response, so don't worry. I'm not asking you to give me a rundown of Torvalds' career.  I'm asking you specifically what his opinion on the use of the goto, as expressed in a fairly obscure mailing list, is doing in this article.  Why is it relevant?  Citing these awards and whatnot does not go towards answering the question. --TS 22:32, 30 January 2010 (UTC)
 * QUOTE: because he's not a *theoretician*, but a notable programmer dealing with practical aspects of code creation. drawing the proper line between theory and practice in IT is obviously important, and he clearly shows the point that was clearly visible in older revisions of the page, dating up to 2001 (http://en.wikipedia.org/w/index.php?title=Goto&oldid=255242) - that gotos may be and often are a reasonable choice in programming. feel free to replace Torvalds' quote with any other *well known software designer's* or *notable programmer's* quote, stating what Torvalds said with as little words and so much precision as he did - i won't object to this, the choice of Linus (*not* Linux - you've made a typo there, mate) was made a priori, just because he fits perfectly for a person to state the unobvious obviousness of the usefulness and harmlessness of gotos.


 * if you need me to Ctrl+C Ctrl+V it a couple of times more, i'm always eager to help. just read it aloud, it's the exact answer to your exact question. if you don't see my point, just ask somebody to explain it to you - some  people are better than me at explaining obviousness... Linus maybe?


 * I read it the first time. Could you now explain why you consider Linus Torvalds to be an authority on programming languages?  It's all I want to know. --TS 11:14, 31 January 2010 (UTC)
 * Ctrl+C Ctrl+V

if you still insist: In 1997 he received his Master degree (Laudatur Grade) from Department of Computer Science, University of Helsinki. In 1998 he received an EFF Pioneer Award.[24] In 1999 he received honorary doctor status at Stockholm University. In 2000 he received honorary doctor status at University of Helsinki.[25] In 2000 he was awarded the Lovelace Medal.[26] (...) In 2004, he was named one of the most influential people in the world by the Time magazine article "Linus Torvalds: The Free-Software Champion" by Lawrence Lessig[28] (...) In August 2005, Torvalds received the Vollum Award from Reed College.[30] In 2006, Time Magazine—Europe Edition named him one of the revolutionary heroes of the past 60 years.[32] In 2008, he was inducted into the Hall of Fellows of the Computer History Museum in Mountain View, California.[33][34] please do some research on these awards...

they aren't given to random people with no knowledge of CS, and they are given to people both widely respected, acknowledged and influential. isn't that enough for someone's opinion on the subject to be notable enough to matter?

http://en.wikipedia.org/wiki/Wikipedia:Notability_(people)

it's quite easy to prove Linus Torvalds' notability in the field of programming. developing and maintaining the world's most known free-source operating system should be enough by itself;

so please, either prove that Torvalds SHOULD'T be considered an authority when it comes to CS in his field of interest (and low-level programming is DIRECTLY related to GOTO use - PLEASE do the research on your own, because the relation it's quite obvious to anybody with a basic knowledge of assembler/C/kernel programming), or declare the dispute closed.


 * I don't subscribe to the notability guideline precisely because it's so often misused (as it is here). In my opinion the statement of Torvalds, given off-the-cuff on a website devoted to kernel development in C, fits poorly with the scholarly opinions of Knuth and Dijkstra.  The main problem, however, was an extensive verbatim quote (including email headers) from that email, which far outbalanced the entire section.  I've remedied that problem and I'll leave it there. --TS 18:40, 31 January 2010 (UTC)

GOTO - isn't "break" and "continue" just an internal goto ( compiler supplies the label). Is a pointer a calculated goto ( ie GOTO variable - really old construction, apparently abandoned because it causes as much problems as pointers) —Preceding unsigned comment added by 159.105.80.141 (talk) 13:14, 19 May 2010 (UTC)

The referenced person is clearly used as an example which is helpful. Besides without links/ references everything would have to be fully explained (Ctrl+C, Cntrl+V) on every wiki page. This point/ argument is isomorphic to the article's argument on goto's controversy, and that is quite cute.

Unconditional
Goto should be described as an unconditional jump. A plain goto is not a branching statement. Only if goto is preceded by an if (or similar) it works in a conditional way. (or if it's a computed goto or any of the more exotic variants) — Preceding unsigned comment added by 88.112.175.168 (talk) 08:05, 25 September 2011 (UTC)


 * Sorry, but that's nonsense steeped in pedantry. If you want to make a distinction between conditional branching and unconditional branching do so, but both forms of branching are still branching nonetheless.Tgm1024 (talk) 16:07, 28 July 2014 (UTC)

Criticism and Decline
Regarding the request for citations starting:

Some[which?] programming style coding standards prohibit...

Possible citations are

"It is good programming style to use the break, continue, and return statement in preference to goto whenever possible."

"Chapter 7: Centralized exiting of functions

Albeit deprecated by some people, the equivalent of the goto statement is used frequently by compilers..."

The python discussion about a Python goto is quite interesting "This PEP is not a proposal to add GOTO to Python. GOTO allows a programmer to jump to an arbitrary block or line of code, and generally makes control flow more difficult to follow."

It might be helpful to rephrase the sentence:

Some programming style coding standards discourage... while some do not

ProgrammerMax (talk) 20:40, 6 April 2012 (UTC)


 * If the only reason why "goto" should not be use, is that the program can not be checked : it's not a good reason : optimized code is necessarily hard to check. Code is not designed to be checked, but to be the fastest and the shortest : with the best reuse of instruction, and the less redundancy of tasks (such as done/undone/done/undone). Goto is simply necessary. — Preceding unsigned comment added by 137.129.13.90 (talk) 16:18, 11 September 2012 (UTC)

Dijkstra didn't propose the title "goto considered harmful", it was Niklaus Wirth
Dijkstra claims that "goto considered harmful" was not the original title of his article. The title was changed by the editor, Niklaus Wirth.

Dijkstra tells the story in this video beginning at 4:22: http://www.youtube.com/watch?v=40CNRVHLt7A&feature=player_detailpage&list=PL7D42CB0A207D79B6#t=255s Prof. Edsger Dijkstra on "Structured Programming" at "Software Pioneers",sd&m Conference 2001, Bonn, Germany

I don't have time to transcribe the story now but it would be a good addition (and correction) to this article.

I haven't read the "considered harmful" paper in a while, but going by what Dijkstra says in the video, the paper is an analysis, not a criticism in the derogatory sense -- in which case the current wording of the wikipedia article is biased.

Ross bencina (talk) 05:38, 5 January 2013 (UTC)

Original title was "A Case Against the Goto Statement". You're kind of right on this one, Ross. AFAIR, it was along the lines you're talking about - the whole 'criticism' was the result of a style war that erupted *after* the article, not the article itself IMO. Still, Dijjie said in that article: "The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one's program."

It IS a negative criticism, but Dij says himself that it's his *opinion*, based on what he seen - not an arbitrary, scientific fact. And I'm with him on this one.

Further reading: Considered harmful

Vaxquis (talk) 17:31, 11 April 2013 (UTC)

Criticism and decline out of date statement
The section states that MISRA C Coding Standard prohibit the use of GOTO statements. This is not the case since MISRA2012: Simzer (talk) 15:33, 27 June 2013 (UTC)
 * MISRA C:2004 Rule 14.4 (required): The goto statement shall not be used
 * MISRA C:2012 Rule 15.1 (advisory): The goto statement should not be used

Apple
Is Apples Security failure missing in the article? :) 87.78.122.110 (talk) 20:00, 23 February 2014 (UTC)

"An empirical study of goto in C code"
"An empirical study of goto in C code" (2015 paper) https://peerj.com/preprints/826v1.pdf and https://peerj.com/preprints/826v1/

"We conclude that developers limit themselves to using goto appropriately in most cases, thus suggesting that goto does not appear to be harmful in practice."

• Sbmeirow  •  Talk  • 21:51, 16 February 2015 (UTC)

Misc
select case/etc are just computed goto - same use/results/speed. If they weren't the same programs would run really slow - half the assembly codes would be unsued. 2601:181:8000:D6D0:7855:5B43:1B2A:B0F4 (talk) 16:23, 5 May 2016 (UTC)

External links modified
Hello fellow Wikipedians,

I have just modified 2 external links on Goto. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
 * Corrected formatting/usage for http://kerneltrap.org/node/553/2131
 * Added archive https://web.archive.org/web/20160526142532/http://www.lahey.com/docs/lfprohelp/F95ARComputed_GOTOStmt.htm to http://www.lahey.com/docs/lfprohelp/F95ARComputed_GOTOStmt.htm

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

Cheers.— InternetArchiveBot  (Report bug) 13:19, 23 March 2017 (UTC)

External links modified
Hello fellow Wikipedians,

I have just modified one external link on Goto. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
 * Added archive https://web.archive.org/web/20100214095828/http://kerneltrap.org/node/553 to http://kerneltrap.org/node/553

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

Cheers.— InternetArchiveBot  (Report bug) 16:04, 21 October 2017 (UTC)

External Link Dead
The link to this doesn't work any longer: Sexton, Alex. "The Summer of Goto | Official Home of Goto.js". Retrieved April 28, 2012. Mikael4u (talk) 21:07, 17 April 2021 (UTC)

APL
In APL there is no alternative to 'goto'-like branching, because it does not have instructions like if/else/switch. How about include a section about good branching techniques for such kind of programming languages? — Preceding unsigned comment added by 179.236.47.163 (talk) 23:07, 26 June 2018 (UTC)

Here is an interesting reference (see pages 10-11): [//ekevanbatenburg.nl/DOWNLOADS/ASWIEKE.PDF ASWIEKE.PDF] — Preceding unsigned comment added by 179.236.87.112 (talk) 19:52, 6 July 2018 (UTC)

Wheeler jump = gosub, not goto
The Wheeler jump was the prototype for a subroutine jump -- i.e., save current instruction counter somewhere such that it can be used for subroutine return -- and not for a simple goto. The EDSAC already had 'goto' in the hardware: branch instructions E and G. What Wheeler devised was the coding sequences for 'save position and branch to specified location' and 'branch to saved position'. This is tantamount to inventing the closed subroutine.

The IEEE citation unfortunately described this as the 'precursor to goto' rather than 'precursor to gosub', an error that ought to be obvious since it also says 'to allow a program to pass control to a subroutine'. — Preceding unsigned comment added by 108.20.234.238 (talk) 21:37, 22 September 2018 (UTC)


 * I agree. That description of the Wheeler jump is fairly obviously a mistake in the IEEE citation. I have made a first attempt at correcting this section. --Stephen lamppost (talk) 16:48, 4 February 2019 (UTC)

Bohm and Jacopini didn't claim
The Bohm and Jacopini paper "Flow Diagrams, Turing Machines and Languages with Only Two Formation Rules", didn't claim, much less prove, "that the goto statement is not necessary to write programs"; the scope of the paper was limited to programs that could be expressed as flow charts. It did not cover programs with subroutines, much less goto statements that unwound the stack. Shmuel (Seymour J.) Metz Username:Chatul (talk) 16:13, 15 August 2019 (UTC)

Perl Goto
Article says "In Perl, there is a variant of the goto statement that is not a traditional GOTO statement at all. It takes a function name and transfers control by effectively substituting one function call for another (a tail call): the new function will not return to the GOTO, but instead to the place from which the original function was called."

This is absolutely a traditional GOTO; you can do exactly that with an ordinary jump instruction in machine code.

It's just not "traditional" in the narrow context of the history of a family of higher level languages that have always had a restricted form of GOTO.

Moreover, of course "the new function will not return to the GOTO"; GOTO isn't expected to return, unless it is GOSUB: a subroutine calling form of GOTO.

KazKylheku (talk) 19:38, 9 December 2020 (UTC)

Vague wording in article summary
“Many languages support the goto statement, and many do not”

I feel that this statement is so vague as to be pointless at best and confusing at worst. This is because it’s phrased as a quantitative comparison.

I propose that we rephrase it to either include a good faith qualitative comparison of languages with support versus languages without support, or we use clearer wording such as, “there is now a considerable mix of languages support the goto statement in different methods.”

Any thoughts on this? ChiXiStigma (talk) 07:48, 5 August 2022 (UTC)