Jump to content

Talk:Infinite loop

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 68.173.113.106 (talk) at 21:57, 3 February 2012 (Java: Fixed by changing to <source> tag). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconComputing Start‑class
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.
WikiProject iconComputer science Start‑class Mid‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-importance on the project's importance scale.
Things you can help WikiProject Computer science with:

Infinite loops found in society??

Wtf is the deal with this section? This article is part of the computer science wikiproject. It is not social science. 66.190.142.200 (talk) 08:11, 6 April 2008 (UTC)[reply]

I want to point out that I just checked the "citation" Rmarkosian gives in the "infinite loops in society" paragraph. It redirects to a website he made himself. It has absolutely ZERO to do with the topic of this article and I have removed it accordingly. That is ridiculous. 66.190.142.200 (talk) 08:19, 6 April 2008 (UTC)[reply]

The example in BASIC

If a programmer were to create that 2-line example in QBASIC, QuickBASIC, or similar interpreter/compiler it would not be an infinite loop. The program would crash when it runs out of stack space. I changed it to:

DO
LOOP UNTIL a <> 0

This is a more correct example, as a DO LOOP instruction will not store a location in the stack for use by the RETURN function like a GOTO call does. —Preceding unsigned comment added by 66.190.142.200 (talk) 01:05, 6 April 2008 (UTC)[reply]

What a joke!

The joke here (for the non-computer-programmer) is that infinite loop links to endless loop which links to infinite loop which links to endless loop which links to infinite loop which links to endless loop which links to infinite loop which links to endless loop which links to infinite loop which links to endless loop which links to infinite loop which links to endless loop which links to infinite loop which links to endless loop which links to infinite loop which links to endless loop which . . .

yes that's funny, but at the same time, not particularly helpful... sorry. Wesley
Can't there be any jokes in the Wikipedia? Sheesh! (I won't un-revert if someone de-humorizes them.) User:Ed Poor
There are Jokes in Wikipedia, as well as humour, laughs, fun and even Sheesh!

But surely they are not the same thing.

I suggest that:

  • An endless loop is any loop that connects back to its self with no way of getting out.
  • An infinite loop is a loop constructed of an infinite number of instructions and therefore only loops back after an infinite amount of time, or, more practically, never.

user:Perry Bebbington

I've never heard infinite loop used to mean this. I've always heard infinite loop used in the meaning above for endless loop: it is defined this way in the Jargon Lexicon at http://www.tuxedo.org/~esr/jargon/ endless loop does not appear there. -- Olof



Thank you, Axel and Lee. It looks just about finished now. User:Ed Poor, unoffical "spirit of Larry"


Fair enough. user:Perry Bebbington

It seems fair game to link them to each other, it is not like the article was deleted to just include the other link! —Preceding unsigned comment added by Bennyj600 (talkcontribs) 21:54, 27 April 2009 (UTC)[reply]

Misnomer.

I'm actually a little tiny bit surprised that there is no mention that this is technically a misnomer. For something to be infinite, it must be growing without bounds. I have yet to see a program loop that "grows" let alone increases the rate of growth. Additionally, these loops all terminate - if nothing else, the programmer will pull the plug on the machine; the loop will stop. --Connel MacKenzie 06:24, Apr 6, 2005 (UTC)

Kind of a bizarre over-interpretation of the words, so not surprising no one would mention it. Also, only possible to "pull the plug" on a physical machine; the concept applies to theoretical constructs such as Turing machines, no plug-pulling there. Stan 14:09, 6 Apr 2005 (UTC)
In a theoretically exact implementation, the time required to execute the loop is infinite Superm401 01:55, Apr 14, 2005 (UTC).
I agree with the misnomer notion. While you surely cannot pull the plug on a theoretical construct like a turing machine, it is still misleading to call the concept "infinite loop". At every point in time it will only have executed a finite number of iterations, and it will never enter its "infinite-th" iteration. That is the same misconception that leads some people to believe the integers actually contain an element "infinity". They grow without bound, their cardinality is infinite, but every single one of them is finite. There may be valid theoretical constructs that allow a loop to execute an infinite number of iterations (maybe related to Omega language), but that's probably not the concept written about in this article.
I also find it strange to talk about the time needed to "execute" an endless loop. Since they do not end by definition, even an infinite amount of time won't bring an endless loop to its end. In short, endless loops are not executable in the usual sense - they wouldn't cause programmers headaches if they were.
So, I'm voting for the term "endless loop" or at least a clarification of both terms, since "loop without end" is what they are, not "loop running/having run for an infinite time/nr. of iterations". If no one objects, I'm gonna add a clarification myself. Catskineater (talk) 03:45, 12 January 2010 (UTC)[reply]
Similarly you could say that it's not an endless loop — the loop ends when you pull the plug. I fail to see how "endless loop" is an improvement. The term "infinite loop" is ubiquitous in programming lingo, we should stick to that. -- intgr [talk] 22:32, 13 January 2010 (UTC)[reply]

Recursion unimportant?

Infinite recursion redirects to infinite loop. A combined discussion might be useful, but there isn't anything about recursion there at all. Similarly, stack overflow (the result of infinite recursion!) redirects to buffer overflow, which is unreleated (although buffers that overflow onto the stack could be called a stack overflow, that's not the only kind of stack overflow). Is there some reason that there's no discussion of the subject at any of the expected places? Is infinite recursion considered insufficiently notable when divorced from other problems? --Tardis 01:09, 4 May 2005 (UTC)[reply]

Infinite recursion rewrite

Technically, an infinite loop can only occur in iterative programming, which is programming that repeats itself until some condition is met. However, infinite recursion can occur in recursive programming, and an infinitely recursive sequence can be seen as a pseudo-infinite loop. Recursive functions operate by solving part of a problem, then calling on themselves to solve the rest. For example, a recursive function to sum the numbers up to a number n might add n to the sum of the numbers up to n-1. The way this process ends is with a special case. In this situation, for instance, if n were 1 the function would return 1. It is possible to create infinite recursion by failing to have that ending condition, meaning the function theoretically calls itself forever. (It would actually run out of stack space.) Recursion is perfectly safe with an adequate ending condition.

I rewrote this. The distinction given between infinite loop and infinite recursion above isn't exact (see "LAMBDA: The Ultimate GOTO" by Guy Steele). I used the same example (plus a more trivial one), but with code. --Mgreenbe 13:41, 23 January 2006 (UTC)[reply]

This should...

... null result. -- Chris 18:14, 5 November 2006 (UTC)[reply]

tight loop

Tight loop links to this article. Is it the same as infinite loop? --Abdull 08:02, 6 July 2007 (UTC)[reply]

No. A tight loop is a loop with few instructions in the body that's executed many times (they are prime candidates for optimization). Infinite loops are often tight, but a tight loop is rarely infinite. The term "tight loop" doesn't warrant a separate article; at best it's dictionary material. The redirect isn't really appropriate, though. 82.95.254.249 15:15, 30 September 2007 (UTC)[reply]

Request for addition

Is there any standard/provable practices for avoiding and/or detecting infinite loops in a system? Can a check be made to the effect of "is this instruction causing an infinite loop? Or is that perhaps, on the contrary, theoretically impossible due to the halting problem? If so, a link and a blurb about how this problem relates to infinite loops would be useful. —Preceding unsigned comment added by 83.89.0.118 (talk) 12:56, 27 July 2008 (UTC) I see now that there is actually a very brief paragraph linking to the halting problem. I still think it would be nice if it was featured more prominently. —Preceding unsigned comment added by 83.89.0.118 (talk) 13:02, 27 July 2008 (UTC)[reply]

...it has been done so many times because it is funny and encyclopedic. This page is surely an exception to the "no self-links" rule, which is overwritten by the democratic rule of Wikipedia (the number of people wanting to add the link is greater than the number of people wanting to remove it). Please tell us why this argument is invalid or I'll add the link. ··gracefool 10:21, 10 July 2009 (UTC)[reply]

Could not agree more. The somewhat snarky HTML comment in that section notwithstanding, it's exactly what that section needs. It's "been done, many times", because it's AWESOME. —Preceding unsigned comment added by 203.26.95.65 (talk) 05:09, 7 May 2010 (UTC)[reply]

C++ Example

I added one that is a perfect infinite loop, correct? —Preceding unsigned comment added by Segiddins (talkcontribs) 00:55, 19 July 2009 (UTC)[reply]

while ( true )

Is it considered bad form to use while ( true )? E.g.,

while ( true ) {
    if ( $foo->bar () ){
        return;
    }
}

This is a simplistic example since here one could just as easily use

while ( !$foo->bar () ) {}

However, I'm sure we have all run into situations in which it was tempting to use a while ( true ), but is it bad form? Tisane talk/stalk 15:33, 16 June 2010 (UTC)[reply]

the rule is that every loop terminates, and when you pretend it doesn't like that, it makes the code harder to read. The example you gave is trivial, and all programming readability conventions can be ignored for trivial cases.
int main()
{
   while(1)
   {
       /* do your main program loop in all its complexity*/
       if(exitCodeReceied)
           break;
       /*Do even more*/
   }
}
You can see how someone coming by later would have a hard time knowing what was going on. The condiiton at the top of the loop helps because it provides immediate context. i kan reed (talk) 16:59, 7 June 2011 (UTC)[reply]
There are some scenarios where while(true) is useful. In such cases I find it is generally useful to add a comment noting where I expect the loop to terminate, eg:
int main()
{
   while(1) // ... until break when exitCodeReceived
   {
       /* do your main program loop in all its complexity*/
       if(exitCodeReceived)
           break;
       /*Do even more*/
   }
}
Mitch Ames (talk) 10:39, 9 June 2011 (UTC)[reply]

Image should be removed

The image has nothing to do with the subject matter of the article, leading to confusion. There is an article on the street, this image does not belong here. —Preceding unsigned comment added by 142.103.72.44 (talk) 16:57, 14 July 2010 (UTC)[reply]

Merger proposal

Alderson loop is a short article should be merged here. The loop is nothing special, it's just a common type of infinite loops and there is no reason to keep it as a separate article. Zakhalesh (talk) 17:40, 19 February 2011 (UTC)[reply]

No opposing opinions, so I'll get on with the merge. Zakhalesh (talk) 10:33, 26 February 2011 (UTC)[reply]

Done. Improve the section if you wish! Zakhalesh (talk) 10:56, 26 February 2011 (UTC)[reply]

Redirect

This should be redirected to Infinite loop. Ten Pound Hammer, his otters and a clue-bat • (Otters want attention) 01:58, 15 April 2011 (UTC)[reply]

Java

A humorous example of an infinite loop in Java:

for ( ; ; )
{
System.out.println("Alice: When are you going to stop looping?");
System.out.println("Bob: Just one more time!");
}

Maybe we could include it, but IDK what section. Thanks! 68.173.113.106 (talk) 21:46, 3 February 2012 (UTC)[reply]