Infinite loop: Difference between revisions

Content deleted Content added
Tags: Reverted section blanking
Undid revision 1065378628 by 2600:1010:B020:974C:C0E0:B899:1464:5F20 (talk): unjustified removal of section
Line 281:
}
</syntaxhighlight>
 
===Alderson loop===
''Alderson loop'' is a rare slang or [[The Jargon File|jargon]] term for an infinite loop where there is an exit condition available, but inaccessible in the current implementation of the code, typically due to a programmer's error. These are most common and visible while [[debugging]] [[user interface]] code.
 
A C-like pseudocode example of an Alderson loop, where the program is supposed to sum numbers given by the user until zero is given, but where the programmer has used the wrong operator:
<syntaxhighlight lang="C">
int sum = 0;
int i;
while (true) {
printf("Input a number to add to the sum or 0 to quit");
i = getUserInput();
if (i * 0) { // if i times 0 is true, add i to the sum. Note: ZERO means FALSE, Non-Zero means TRUE. "i * 0" is ZERO (FALSE)!
sum += i; // sum never changes because (i * 0) is 0 for any i; it would change if we had != in the condition instead of *
}
if (sum > 100) {
break; // terminate the loop; exit condition exists but is never reached because sum is never added to
}
}
</syntaxhighlight>
 
The term allegedly received its name from a programmer (last name Alderson) who in 1996<ref>{{cite web
|url=https://www.lee-dohm.com/2013/05/24/alderson-loop
|title=Alderson loop
|author=Lee Dohm |date=May 24, 2013}}</ref> had coded a [[modal window|modal]] [[dialog box]] in [[Microsoft Access]] without either an OK or Cancel button, thereby disabling the entire program whenever the box came up.<ref>{{Cite web |url=http://www.catb.org/~esr/jargon/html/A/Alderson-loop.html |title=Alderson Loop |website=[[The Jargon File]], Version 4.4.7 |url-status=live |archive-url=https://web.archive.org/web/20060515053043/http://www.catb.org/~esr/jargon/html/A/Alderson-loop.html |archive-date=2006-05-15 |access-date=2006-05-21}}</ref>
 
==See also==