CINXE.COM

Control flow - Wikipedia

<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Control flow - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"f3f69a25-e5f4-417e-9c6b-13d9101a3b0d","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Control_flow","wgTitle":"Control flow","wgCurRevisionId":1283356404,"wgRevisionId":1283356404,"wgArticleId":45459,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Webarchive template wayback links","Articles with short description","Short description is different from Wikidata","All articles with unsourced statements","Articles with unsourced statements from July 2014","Wikipedia articles needing clarification from November 2015","Articles with example Python (programming language) code","Commons category link from Wikidata","Articles with example Ada code","Articles with example ALGOL 60 code","Articles with example ALGOL 68 code","Articles with example C code","Articles with example C++ code","Articles with example C Sharp code","Articles with example D code","Articles with example Fortran code","Articles with example Haskell code","Articles with example Java code","Articles with example JavaScript code","Articles with example Lisp (programming language) code","Articles with example MATLAB/Octave code","Articles with example Pascal code","Articles with example Perl code","Articles with example PHP code","Articles with example Ruby code","Articles with example Smalltalk code","Control flow","Iteration in programming","Programming language comparisons","Recursion"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Control_flow","wgRelevantArticleId":45459,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":60000,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q868299","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGELevelingUpEnabledForUser":false}; RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.pygments":"ready","ext.cite.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready"};RLPAGEMODULES=["ext.pygments.view","ext.cite.ux-enhancements","mediawiki.page.media","site","mediawiki.page.ready","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.quicksurveys.init","ext.growthExperiments.SuggestedEditSession"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=ext.cite.styles%7Cext.pygments%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&amp;only=styles&amp;skin=vector-2022"> <script async="" src="/w/load.php?lang=en&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=site.styles&amp;only=styles&amp;skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.22"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Control flow - Wikipedia"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/Control_flow"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Control_flow&amp;action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/Control_flow"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&amp;feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="auth.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Control_flow rootpage-Control_flow skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" title="Main menu" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li> </ul> </div> </div> <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" > <div class="vector-menu-heading"> Contribute </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li><li id="n-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages"><span>Special pages</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Main_Page" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page&#039;s font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/?wmf_source=donate&amp;wmf_medium=sidebar&amp;wmf_campaign=en.wikipedia.org&amp;uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&amp;returnto=Control+flow" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&amp;returnto=Control+flow" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/?wmf_source=donate&amp;wmf_medium=sidebar&amp;wmf_campaign=en.wikipedia.org&amp;uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&amp;returnto=Control+flow" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&amp;returnto=Control+flow" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">(Top)</div> </a> </li> <li id="toc-Categories" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Categories"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Categories</span> </div> </a> <ul id="toc-Categories-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Primitives" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Primitives"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Primitives</span> </div> </a> <button aria-controls="toc-Primitives-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Primitives subsection</span> </button> <ul id="toc-Primitives-sublist" class="vector-toc-list"> <li id="toc-Labels" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Labels"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Labels</span> </div> </a> <ul id="toc-Labels-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Goto" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Goto"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2</span> <span>Goto</span> </div> </a> <ul id="toc-Goto-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Subroutines" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Subroutines"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3</span> <span>Subroutines</span> </div> </a> <ul id="toc-Subroutines-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Sequence" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Sequence"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.4</span> <span>Sequence</span> </div> </a> <ul id="toc-Sequence-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Minimal_structured_control_flow" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Minimal_structured_control_flow"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Minimal structured control flow</span> </div> </a> <ul id="toc-Minimal_structured_control_flow-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Control_structures_in_practice" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Control_structures_in_practice"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Control structures in practice</span> </div> </a> <ul id="toc-Control_structures_in_practice-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Choice" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Choice"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Choice</span> </div> </a> <button aria-controls="toc-Choice-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Choice subsection</span> </button> <ul id="toc-Choice-sublist" class="vector-toc-list"> <li id="toc-If-then-(else)_statements" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#If-then-(else)_statements"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>If-then-(else) statements</span> </div> </a> <ul id="toc-If-then-(else)_statements-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Case_and_switch_statements" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Case_and_switch_statements"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2</span> <span>Case and switch statements</span> </div> </a> <ul id="toc-Case_and_switch_statements-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Loops" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Loops"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Loops</span> </div> </a> <button aria-controls="toc-Loops-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Loops subsection</span> </button> <ul id="toc-Loops-sublist" class="vector-toc-list"> <li id="toc-Count-controlled_loops" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Count-controlled_loops"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.1</span> <span>Count-controlled loops</span> </div> </a> <ul id="toc-Count-controlled_loops-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Condition-controlled_loops" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Condition-controlled_loops"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.2</span> <span>Condition-controlled loops</span> </div> </a> <ul id="toc-Condition-controlled_loops-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Collection-controlled_loops" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Collection-controlled_loops"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3</span> <span>Collection-controlled loops</span> </div> </a> <ul id="toc-Collection-controlled_loops-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-General_iteration" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#General_iteration"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.4</span> <span>General iteration</span> </div> </a> <ul id="toc-General_iteration-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Infinite_loops" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Infinite_loops"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.5</span> <span>Infinite loops</span> </div> </a> <ul id="toc-Infinite_loops-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Continuation_with_next_iteration" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Continuation_with_next_iteration"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.6</span> <span>Continuation with next iteration</span> </div> </a> <ul id="toc-Continuation_with_next_iteration-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Redo_current_iteration" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Redo_current_iteration"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.7</span> <span>Redo current iteration</span> </div> </a> <ul id="toc-Redo_current_iteration-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Restart_loop" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Restart_loop"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.8</span> <span>Restart loop</span> </div> </a> <ul id="toc-Restart_loop-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Early_exit_from_loops" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Early_exit_from_loops"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.9</span> <span>Early exit from loops</span> </div> </a> <ul id="toc-Early_exit_from_loops-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Loop_variants_and_invariants" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Loop_variants_and_invariants"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.10</span> <span>Loop variants and invariants</span> </div> </a> <ul id="toc-Loop_variants_and_invariants-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Loop_sublanguage" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Loop_sublanguage"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.11</span> <span>Loop sublanguage</span> </div> </a> <ul id="toc-Loop_sublanguage-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Loop_system_cross-reference_table" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Loop_system_cross-reference_table"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.12</span> <span>Loop system cross-reference table</span> </div> </a> <ul id="toc-Loop_system_cross-reference_table-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Structured_non-local_control_flow" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Structured_non-local_control_flow"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>Structured non-local control flow</span> </div> </a> <button aria-controls="toc-Structured_non-local_control_flow-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Structured non-local control flow subsection</span> </button> <ul id="toc-Structured_non-local_control_flow-sublist" class="vector-toc-list"> <li id="toc-Conditions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Conditions"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.1</span> <span>Conditions</span> </div> </a> <ul id="toc-Conditions-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Exceptions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Exceptions"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.2</span> <span>Exceptions</span> </div> </a> <ul id="toc-Exceptions-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Continuations" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Continuations"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.3</span> <span>Continuations</span> </div> </a> <ul id="toc-Continuations-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Async" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Async"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.4</span> <span>Async</span> </div> </a> <ul id="toc-Async-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Generators" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Generators"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.5</span> <span>Generators</span> </div> </a> <ul id="toc-Generators-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Coroutines" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Coroutines"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.6</span> <span>Coroutines</span> </div> </a> <ul id="toc-Coroutines-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Non-local_control_flow_cross_reference" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Non-local_control_flow_cross_reference"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.7</span> <span>Non-local control flow cross reference</span> </div> </a> <ul id="toc-Non-local_control_flow_cross_reference-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Proposed_control_structures" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Proposed_control_structures"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>Proposed control structures</span> </div> </a> <button aria-controls="toc-Proposed_control_structures-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Proposed control structures subsection</span> </button> <ul id="toc-Proposed_control_structures-sublist" class="vector-toc-list"> <li id="toc-Loop_with_test_in_the_middle" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Loop_with_test_in_the_middle"> <div class="vector-toc-text"> <span class="vector-toc-numb">8.1</span> <span>Loop with test in the middle</span> </div> </a> <ul id="toc-Loop_with_test_in_the_middle-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Multiple_early_exit/exit_from_nested_loops" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Multiple_early_exit/exit_from_nested_loops"> <div class="vector-toc-text"> <span class="vector-toc-numb">8.2</span> <span>Multiple early exit/exit from nested loops</span> </div> </a> <ul id="toc-Multiple_early_exit/exit_from_nested_loops-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Security" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Security"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>Security</span> </div> </a> <ul id="toc-Security-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">10</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Notes" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Notes"> <div class="vector-toc-text"> <span class="vector-toc-numb">11</span> <span>Notes</span> </div> </a> <ul id="toc-Notes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">12</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Further_reading" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Further_reading"> <div class="vector-toc-text"> <span class="vector-toc-numb">13</span> <span>Further reading</span> </div> </a> <ul id="toc-Further_reading-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">14</span> <span>External links</span> </div> </a> <ul id="toc-External_links-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" title="Table of Contents" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Control flow</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Go to an article in another language. Available in 33 languages" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-33" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">33 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-ar mw-list-item"><a href="https://ar.wikipedia.org/wiki/%D8%A7%D9%86%D8%B3%D9%8A%D8%A7%D8%A8_%D8%A7%D9%84%D8%AA%D8%AD%D9%83%D9%85" title="انسياب التحكم – Arabic" lang="ar" hreflang="ar" data-title="انسياب التحكم" data-language-autonym="العربية" data-language-local-name="Arabic" class="interlanguage-link-target"><span>العربية</span></a></li><li class="interlanguage-link interwiki-az mw-list-item"><a href="https://az.wikipedia.org/wiki/N%C9%99zar%C9%99t_ax%C4%B1n%C4%B1" title="Nəzarət axını – Azerbaijani" lang="az" hreflang="az" data-title="Nəzarət axını" data-language-autonym="Azərbaycanca" data-language-local-name="Azerbaijani" class="interlanguage-link-target"><span>Azərbaycanca</span></a></li><li class="interlanguage-link interwiki-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Estructura_de_control" title="Estructura de control – Catalan" lang="ca" hreflang="ca" data-title="Estructura de control" data-language-autonym="Català" data-language-local-name="Catalan" class="interlanguage-link-target"><span>Català</span></a></li><li class="interlanguage-link interwiki-cs mw-list-item"><a href="https://cs.wikipedia.org/wiki/%C5%98%C3%ADdic%C3%AD_struktura" title="Řídicí struktura – Czech" lang="cs" hreflang="cs" data-title="Řídicí struktura" data-language-autonym="Čeština" data-language-local-name="Czech" class="interlanguage-link-target"><span>Čeština</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Kontrollstruktur" title="Kontrollstruktur – German" lang="de" hreflang="de" data-title="Kontrollstruktur" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Estructuras_de_control" title="Estructuras de control – Spanish" lang="es" hreflang="es" data-title="Estructuras de control" data-language-autonym="Español" data-language-local-name="Spanish" class="interlanguage-link-target"><span>Español</span></a></li><li class="interlanguage-link interwiki-eo mw-list-item"><a href="https://eo.wikipedia.org/wiki/Stirfluo" title="Stirfluo – Esperanto" lang="eo" hreflang="eo" data-title="Stirfluo" data-language-autonym="Esperanto" data-language-local-name="Esperanto" class="interlanguage-link-target"><span>Esperanto</span></a></li><li class="interlanguage-link interwiki-eu mw-list-item"><a href="https://eu.wikipedia.org/wiki/Kontrol-egitura" title="Kontrol-egitura – Basque" lang="eu" hreflang="eu" data-title="Kontrol-egitura" data-language-autonym="Euskara" data-language-local-name="Basque" class="interlanguage-link-target"><span>Euskara</span></a></li><li class="interlanguage-link interwiki-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%DA%A9%D9%86%D8%AA%D8%B1%D9%84_%D8%AC%D8%B1%DB%8C%D8%A7%D9%86" title="کنترل جریان – Persian" lang="fa" hreflang="fa" data-title="کنترل جریان" data-language-autonym="فارسی" data-language-local-name="Persian" class="interlanguage-link-target"><span>فارسی</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Structure_de_contr%C3%B4le" title="Structure de contrôle – French" lang="fr" hreflang="fr" data-title="Structure de contrôle" data-language-autonym="Français" data-language-local-name="French" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%EC%A0%9C%EC%96%B4_%ED%9D%90%EB%A6%84" title="제어 흐름 – Korean" lang="ko" hreflang="ko" data-title="제어 흐름" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-hr mw-list-item"><a href="https://hr.wikipedia.org/wiki/Kontrolna_struktura" title="Kontrolna struktura – Croatian" lang="hr" hreflang="hr" data-title="Kontrolna struktura" data-language-autonym="Hrvatski" data-language-local-name="Croatian" class="interlanguage-link-target"><span>Hrvatski</span></a></li><li class="interlanguage-link interwiki-is mw-list-item"><a href="https://is.wikipedia.org/wiki/Lykkja_(forritun)" title="Lykkja (forritun) – Icelandic" lang="is" hreflang="is" data-title="Lykkja (forritun)" data-language-autonym="Íslenska" data-language-local-name="Icelandic" class="interlanguage-link-target"><span>Íslenska</span></a></li><li class="interlanguage-link interwiki-it mw-list-item"><a href="https://it.wikipedia.org/wiki/Struttura_di_controllo" title="Struttura di controllo – Italian" lang="it" hreflang="it" data-title="Struttura di controllo" data-language-autonym="Italiano" data-language-local-name="Italian" class="interlanguage-link-target"><span>Italiano</span></a></li><li class="interlanguage-link interwiki-he mw-list-item"><a href="https://he.wikipedia.org/wiki/%D7%91%D7%A7%D7%A8%D7%AA_%D7%96%D7%A8%D7%99%D7%9E%D7%94" title="בקרת זרימה – Hebrew" lang="he" hreflang="he" data-title="בקרת זרימה" data-language-autonym="עברית" data-language-local-name="Hebrew" class="interlanguage-link-target"><span>עברית</span></a></li><li class="interlanguage-link interwiki-kk mw-list-item"><a href="https://kk.wikipedia.org/wiki/%D0%90%D1%8F%D2%9B%D1%82%D0%B0%D0%BB%D1%83_%D0%BE%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80%D1%8B" title="Аяқталу операторы – Kazakh" lang="kk" hreflang="kk" data-title="Аяқталу операторы" data-language-autonym="Қазақша" data-language-local-name="Kazakh" class="interlanguage-link-target"><span>Қазақша</span></a></li><li class="interlanguage-link interwiki-ms mw-list-item"><a href="https://ms.wikipedia.org/wiki/Aliran_kawalan" title="Aliran kawalan – Malay" lang="ms" hreflang="ms" data-title="Aliran kawalan" data-language-autonym="Bahasa Melayu" data-language-local-name="Malay" class="interlanguage-link-target"><span>Bahasa Melayu</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Control_flow" title="Control flow – Dutch" lang="nl" hreflang="nl" data-title="Control flow" data-language-autonym="Nederlands" data-language-local-name="Dutch" class="interlanguage-link-target"><span>Nederlands</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/%E5%88%B6%E5%BE%A1%E6%A7%8B%E9%80%A0" title="制御構造 – Japanese" lang="ja" hreflang="ja" data-title="制御構造" data-language-autonym="日本語" data-language-local-name="Japanese" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-no mw-list-item"><a href="https://no.wikipedia.org/wiki/Kontrollflyt" title="Kontrollflyt – Norwegian Bokmål" lang="nb" hreflang="nb" data-title="Kontrollflyt" data-language-autonym="Norsk bokmål" data-language-local-name="Norwegian Bokmål" class="interlanguage-link-target"><span>Norsk bokmål</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Przep%C5%82yw_sterowania" title="Przepływ sterowania – Polish" lang="pl" hreflang="pl" data-title="Przepływ sterowania" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Estrutura_de_controle" title="Estrutura de controle – Portuguese" lang="pt" hreflang="pt" data-title="Estrutura de controle" data-language-autonym="Português" data-language-local-name="Portuguese" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/%D0%9F%D0%BE%D1%80%D1%8F%D0%B4%D0%BE%D0%BA_%D0%B2%D1%8B%D0%BF%D0%BE%D0%BB%D0%BD%D0%B5%D0%BD%D0%B8%D1%8F" title="Порядок выполнения – Russian" lang="ru" hreflang="ru" data-title="Порядок выполнения" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/%D0%A3%D0%BF%D1%80%D0%B0%D0%B2%D1%99%D0%B0%D1%9A%D0%B5_%D1%82%D0%BE%D0%BA%D0%BE%D0%BC" title="Управљање током – Serbian" lang="sr" hreflang="sr" data-title="Управљање током" data-language-autonym="Српски / srpski" data-language-local-name="Serbian" class="interlanguage-link-target"><span>Српски / srpski</span></a></li><li class="interlanguage-link interwiki-sh mw-list-item"><a href="https://sh.wikipedia.org/wiki/Upravljanje_tokom" title="Upravljanje tokom – Serbo-Croatian" lang="sh" hreflang="sh" data-title="Upravljanje tokom" data-language-autonym="Srpskohrvatski / српскохрватски" data-language-local-name="Serbo-Croatian" class="interlanguage-link-target"><span>Srpskohrvatski / српскохрватски</span></a></li><li class="interlanguage-link interwiki-sv mw-list-item"><a href="https://sv.wikipedia.org/wiki/Programfl%C3%B6de" title="Programflöde – Swedish" lang="sv" hreflang="sv" data-title="Programflöde" data-language-autonym="Svenska" data-language-local-name="Swedish" class="interlanguage-link-target"><span>Svenska</span></a></li><li class="interlanguage-link interwiki-ta mw-list-item"><a href="https://ta.wikipedia.org/wiki/%E0%AE%95%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%BE%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81_%E0%AE%95%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AE%AE%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AF%81" title="கட்டுப்பாட்டு கட்டமைப்பு – Tamil" lang="ta" hreflang="ta" data-title="கட்டுப்பாட்டு கட்டமைப்பு" data-language-autonym="தமிழ்" data-language-local-name="Tamil" class="interlanguage-link-target"><span>தமிழ்</span></a></li><li class="interlanguage-link interwiki-th mw-list-item"><a href="https://th.wikipedia.org/wiki/%E0%B9%82%E0%B8%9F%E0%B8%A5%E0%B8%A7%E0%B9%8C%E0%B8%84%E0%B8%A7%E0%B8%9A%E0%B8%84%E0%B8%B8%E0%B8%A1" title="โฟลว์ควบคุม – Thai" lang="th" hreflang="th" data-title="โฟลว์ควบคุม" data-language-autonym="ไทย" data-language-local-name="Thai" class="interlanguage-link-target"><span>ไทย</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%9F%D0%BE%D1%82%D1%96%D0%BA_%D0%BA%D0%B5%D1%80%D1%83%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F" title="Потік керування – Ukrainian" lang="uk" hreflang="uk" data-title="Потік керування" data-language-autonym="Українська" data-language-local-name="Ukrainian" class="interlanguage-link-target"><span>Українська</span></a></li><li class="interlanguage-link interwiki-ur mw-list-item"><a href="https://ur.wikipedia.org/wiki/%D9%BE%D8%B1%D9%88%DA%AF%D8%B1%D8%A7%D9%85_%DA%A9%D8%A7_%D8%A8%DB%81%D8%A7%D8%A4" title="پروگرام کا بہاؤ – Urdu" lang="ur" hreflang="ur" data-title="پروگرام کا بہاؤ" data-language-autonym="اردو" data-language-local-name="Urdu" class="interlanguage-link-target"><span>اردو</span></a></li><li class="interlanguage-link interwiki-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/Lu%E1%BB%93ng_%C4%91i%E1%BB%81u_khi%E1%BB%83n" title="Luồng điều khiển – Vietnamese" lang="vi" hreflang="vi" data-title="Luồng điều khiển" data-language-autonym="Tiếng Việt" data-language-local-name="Vietnamese" class="interlanguage-link-target"><span>Tiếng Việt</span></a></li><li class="interlanguage-link interwiki-zh-yue mw-list-item"><a href="https://zh-yue.wikipedia.org/wiki/%E6%8E%A7%E5%88%B6%E6%B5%81%E7%A8%8B" title="控制流程 – Cantonese" lang="yue" hreflang="yue" data-title="控制流程" data-language-autonym="粵語" data-language-local-name="Cantonese" class="interlanguage-link-target"><span>粵語</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/%E6%8E%A7%E5%88%B6%E6%B5%81%E7%A8%8B" title="控制流程 – Chinese" lang="zh" hreflang="zh" data-title="控制流程" data-language-autonym="中文" data-language-local-name="Chinese" class="interlanguage-link-target"><span>中文</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q868299#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Control_flow" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Control_flow" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Control_flow"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Control_flow&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Control_flow&amp;action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Control_flow"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Control_flow&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Control_flow&amp;action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Control_flow" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Control_flow" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Control_flow&amp;oldid=1283356404" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Control_flow&amp;action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&amp;page=Control_flow&amp;id=1283356404&amp;wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FControl_flow"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FControl_flow"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&amp;page=Control_flow&amp;action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Control_flow&amp;printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="wb-otherproject-link wb-otherproject-commons mw-list-item"><a href="https://commons.wikimedia.org/wiki/Category:Control_flow" hreflang="en"><span>Wikimedia Commons</span></a></li><li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q868299" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">Execution order of computer commands</div> <style data-mw-deduplicate="TemplateStyles:r1236090951">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}</style><div role="note" class="hatnote navigation-not-searchable">Not to be confused with <a href="/wiki/Flow_control_(data)" title="Flow control (data)">Flow control (data)</a>.</div> <style data-mw-deduplicate="TemplateStyles:r1129693374">.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}</style><style data-mw-deduplicate="TemplateStyles:r1246091330">.mw-parser-output .sidebar{width:22em;float:right;clear:right;margin:0.5em 0 1em 1em;background:var(--background-color-neutral-subtle,#f8f9fa);border:1px solid var(--border-color-base,#a2a9b1);padding:0.2em;text-align:center;line-height:1.4em;font-size:88%;border-collapse:collapse;display:table}body.skin-minerva .mw-parser-output .sidebar{display:table!important;float:right!important;margin:0.5em 0 1em 1em!important}.mw-parser-output .sidebar-subgroup{width:100%;margin:0;border-spacing:0}.mw-parser-output .sidebar-left{float:left;clear:left;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-none{float:none;clear:both;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-outer-title{padding:0 0.4em 0.2em;font-size:125%;line-height:1.2em;font-weight:bold}.mw-parser-output .sidebar-top-image{padding:0.4em}.mw-parser-output .sidebar-top-caption,.mw-parser-output .sidebar-pretitle-with-top-image,.mw-parser-output .sidebar-caption{padding:0.2em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-pretitle{padding:0.4em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-title,.mw-parser-output .sidebar-title-with-pretitle{padding:0.2em 0.8em;font-size:145%;line-height:1.2em}.mw-parser-output .sidebar-title-with-pretitle{padding:0.1em 0.4em}.mw-parser-output .sidebar-image{padding:0.2em 0.4em 0.4em}.mw-parser-output .sidebar-heading{padding:0.1em 0.4em}.mw-parser-output .sidebar-content{padding:0 0.5em 0.4em}.mw-parser-output .sidebar-content-with-subgroup{padding:0.1em 0.4em 0.2em}.mw-parser-output .sidebar-above,.mw-parser-output .sidebar-below{padding:0.3em 0.8em;font-weight:bold}.mw-parser-output .sidebar-collapse .sidebar-above,.mw-parser-output .sidebar-collapse .sidebar-below{border-top:1px solid #aaa;border-bottom:1px solid #aaa}.mw-parser-output .sidebar-navbar{text-align:right;font-size:115%;padding:0 0.4em 0.4em}.mw-parser-output .sidebar-list-title{padding:0 0.4em;text-align:left;font-weight:bold;line-height:1.6em;font-size:105%}.mw-parser-output .sidebar-list-title-c{padding:0 0.4em;text-align:center;margin:0 3.3em}@media(max-width:640px){body.mediawiki .mw-parser-output .sidebar{width:100%!important;clear:both;float:none!important;margin-left:0!important;margin-right:0!important}}body.skin--responsive .mw-parser-output .sidebar a>img{max-width:none!important}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media print{body.ns-0 .mw-parser-output .sidebar{display:none!important}}</style><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><table class="sidebar nomobile nowraplinks"><tbody><tr><th class="sidebar-title"><a class="mw-selflink-fragment" href="#Loops">Loop constructs</a></th></tr><tr><td class="sidebar-content"> <div class="hlist"> <ul><li><a href="/wiki/Do_while_loop" title="Do while loop">Do while loop</a></li> <li><a href="/wiki/While_loop" title="While loop">While loop</a></li> <li><a href="/wiki/For_loop" title="For loop">For loop</a></li> <li><a href="/wiki/Foreach_loop" title="Foreach loop">Foreach loop</a></li> <li><a href="/wiki/Infinite_loop" title="Infinite loop">Infinite loop</a></li> <li><a class="mw-selflink selflink">Control flow</a></li></ul> </div></td> </tr><tr><td class="sidebar-navbar"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><style data-mw-deduplicate="TemplateStyles:r1239400231">.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}</style><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:Loop_constructs" title="Template:Loop constructs"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:Loop_constructs" title="Template talk:Loop constructs"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:Loop_constructs" title="Special:EditPage/Template:Loop constructs"><abbr title="Edit this template">e</abbr></a></li></ul></div></td></tr></tbody></table> <p>In <a href="/wiki/Computer_science" title="Computer science">computer science</a>, <b>control flow</b> (or <b>flow of control</b>) is the order in which individual <a href="/wiki/Statement_(computer_science)" title="Statement (computer science)">statements</a>, <a href="/wiki/Instruction_(computer_science)" class="mw-redirect" title="Instruction (computer science)">instructions</a> or <a href="/wiki/Function_call" class="mw-redirect" title="Function call">function calls</a> of an <a href="/wiki/Imperative_programming" title="Imperative programming">imperative</a> <a href="/wiki/Computer_program" title="Computer program">program</a> are <a href="/wiki/Execution_(computing)" title="Execution (computing)">executed</a> or evaluated. The emphasis on explicit control flow distinguishes an <i><a href="/wiki/Imperative_programming" title="Imperative programming">imperative programming</a></i> language from a <i><a href="/wiki/Declarative_programming" title="Declarative programming">declarative programming</a></i> language. </p><p>Within an imperative <a href="/wiki/Programming_language" title="Programming language">programming language</a>, a <i>control flow statement</i> is a statement that results in a choice being made as to which of two or more paths to follow. For <a href="/wiki/Strict_programming_language" title="Strict programming language">non-strict</a> functional languages, functions and <a href="/wiki/Language_construct" title="Language construct">language constructs</a> exist to achieve the same result, but they are usually not termed control flow statements. </p><p>A set of statements is in turn generally structured as a <a href="/wiki/Block_(programming)" title="Block (programming)">block</a>, which in addition to grouping, also defines a <a href="/wiki/Lexical_scope" class="mw-redirect" title="Lexical scope">lexical scope</a>. </p><p><a href="/wiki/Interrupt" title="Interrupt">Interrupts</a> and <a href="/wiki/Signal_(computing)" class="mw-redirect" title="Signal (computing)">signals</a> are low-level mechanisms that can alter the flow of control in a way similar to a <a href="/wiki/Subroutine" class="mw-redirect" title="Subroutine">subroutine</a>, but usually occur as a response to some external stimulus or event (that can occur <a href="/wiki/Asynchronous_systems" class="mw-redirect" title="Asynchronous systems">asynchronously</a>), rather than execution of an <i>in-line</i> control flow statement. </p><p>At the level of <a href="/wiki/Machine_language" class="mw-redirect" title="Machine language">machine language</a> or <a href="/wiki/Assembly_language" title="Assembly language">assembly language</a>, control flow instructions usually work by altering the <a href="/wiki/Program_counter" title="Program counter">program counter</a>. For some <a href="/wiki/Central_processing_unit" title="Central processing unit">central processing units</a> (CPUs), the only control flow instructions available are conditional or unconditional <a href="/wiki/Branch_(computer_science)" title="Branch (computer science)">branch</a> instructions, also termed jumps. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Categories">Categories</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=1" title="Edit section: Categories"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Maldi_informatics_figure_7.JPG" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Maldi_informatics_figure_7.JPG/330px-Maldi_informatics_figure_7.JPG" decoding="async" width="290" height="272" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Maldi_informatics_figure_7.JPG/500px-Maldi_informatics_figure_7.JPG 1.5x, //upload.wikimedia.org/wikipedia/commons/d/d3/Maldi_informatics_figure_7.JPG 2x" data-file-width="575" data-file-height="539" /></a><figcaption>A <a href="/wiki/State_diagram" title="State diagram">state diagram</a> of a peptide ion mass mapping search process.</figcaption></figure> <p>The kinds of control flow statements supported by different languages vary, but can be categorized by their effect: </p> <ul><li>Continuation at a different statement (unconditional <a href="/wiki/Branch_(computer_science)" title="Branch (computer science)">branch</a> or jump)</li> <li>Executing a set of statements only if some condition is met (choice - i.e., <a href="/wiki/Conditional_branch" class="mw-redirect" title="Conditional branch">conditional branch</a>)</li> <li>Executing a set of statements zero or more times, until some condition is met (i.e., loop - the same as <a href="/wiki/Conditional_branch" class="mw-redirect" title="Conditional branch">conditional branch</a>)</li> <li>Executing a set of distant statements, after which the flow of control usually returns (<a href="/wiki/Subroutine" class="mw-redirect" title="Subroutine">subroutines</a>, <a href="/wiki/Coroutine" title="Coroutine">coroutines</a>, and <a href="/wiki/Continuation" title="Continuation">continuations</a>)</li> <li>Stopping the program, preventing any further execution (unconditional halt)</li></ul> <div class="mw-heading mw-heading2"><h2 id="Primitives">Primitives</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=2" title="Edit section: Primitives"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Labels">Labels</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=3" title="Edit section: Labels"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Label_(computer_science)" title="Label (computer science)">Label (computer science)</a></div> <p>A <a href="/wiki/Label_(programming_language)" class="mw-redirect" title="Label (programming language)">label</a> is an explicit name or number assigned to a fixed position within the <a href="/wiki/Source_code" title="Source code">source code</a>, and which may be referenced by control flow statements appearing elsewhere in the source code. A label marks a position within source code and has no other effect. </p><p><a href="/wiki/Line_number" title="Line number">Line numbers</a> are an alternative to a named label used in some languages (such as <a href="/wiki/BASIC" title="BASIC">BASIC</a>). They are <a href="/wiki/Natural_number" title="Natural number">whole numbers</a> placed at the start of each line of text in the source code. Languages which use these often impose the constraint that the line numbers must increase in value in each following line, but may not require that they be consecutive. For example, in BASIC: </p> <div class="mw-highlight mw-highlight-lang-qbasic mw-content-ltr" dir="ltr"><pre><span></span><span class="nl">10</span><span class="w"> </span><span class="kd">LET</span><span class="w"> </span><span class="vg">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="il">3</span> <span class="nl">20</span><span class="w"> </span><span class="kr">PRINT</span><span class="w"> </span><span class="vg">X</span> </pre></div> <p>In other languages such as <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> and <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>, a label is an <a href="/wiki/Identifier" title="Identifier">identifier</a>, usually appearing at the start of a line and immediately followed by a colon. For example, in C: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="nl">Success</span><span class="p">:</span><span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">&quot;The operation was successful.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span> </pre></div> <p>The language <a href="/wiki/ALGOL_60" title="ALGOL 60">ALGOL 60</a> allowed both whole numbers and identifiers as labels (both linked by colons to the following statement), but few if any other <a href="/wiki/ALGOL" title="ALGOL">ALGOL</a> variants allowed whole numbers. Early <a href="/wiki/Fortran" title="Fortran">Fortran</a> compilers only allowed whole numbers as labels. Beginning with Fortran-90, alphanumeric labels have also been allowed. </p> <div class="mw-heading mw-heading3"><h3 id="Goto">Goto</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=4" title="Edit section: Goto"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/GOTO" class="mw-redirect" title="GOTO">GOTO</a></div> <p>The <i>goto</i> statement (a combination of the English words <i><a href="https://en.wiktionary.org/wiki/go" class="extiw" title="wiktionary:go">go</a></i> and <i><a href="https://en.wiktionary.org/wiki/to" class="extiw" title="wiktionary:to">to</a></i>, and pronounced accordingly) is the most basic form of unconditional transfer of control. </p><p>Although the <a href="/wiki/Keyword_(computing)" class="mw-redirect" title="Keyword (computing)">keyword</a> may either be in upper or lower case depending on the language, it is usually written as: </p> <pre> <b>goto</b> <i>label</i> </pre> <p>The effect of a goto statement is to cause the next statement to be executed to be the statement appearing at (or immediately after) the indicated label. </p><p>Goto statements have been <a href="/wiki/Considered_harmful" title="Considered harmful">considered harmful</a> by many computer scientists, notably <a href="/wiki/Edsger_W._Dijkstra" title="Edsger W. Dijkstra">Dijkstra</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Subroutines">Subroutines</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=5" title="Edit section: Subroutines"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Subroutine" class="mw-redirect" title="Subroutine">Subroutine</a></div> <p>The terminology for <a href="/wiki/Subroutine" class="mw-redirect" title="Subroutine">subroutines</a> varies; they may alternatively be known as routines, procedures, functions (especially if they return results) or methods (especially if they belong to <a href="/wiki/Class_(programming)" class="mw-redirect" title="Class (programming)">classes</a> or <a href="/wiki/Type_class" title="Type class">type classes</a>). </p><p>In the 1950s, computer memories were very small by current standards so subroutines were used mainly to reduce program size. A piece of code was written once and then used many times from various other places in a program. </p><p>Today, subroutines are more often used to help make a program more structured, e.g., by isolating some algorithm or hiding some data access method. If many programmers are working on one program, subroutines are one kind of <a href="/wiki/Modularity_(programming)" class="mw-redirect" title="Modularity (programming)">modularity</a> that can help divide the work. </p> <div class="mw-heading mw-heading3"><h3 id="Sequence">Sequence</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=6" title="Edit section: Sequence"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Structured_programming" title="Structured programming">Structured programming</a></div> <p>In structured programming, the ordered sequencing of successive commands is considered one of the basic control structures, which is used as a building block for programs alongside iteration, recursion and choice. </p> <div class="mw-heading mw-heading2"><h2 id="Minimal_structured_control_flow">Minimal structured control flow</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=7" title="Edit section: Minimal structured control flow"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">See also: <a href="/wiki/Structured_program_theorem" title="Structured program theorem">Structured program theorem</a></div> <p>In May 1966, Böhm and Jacopini published an article<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> in <i>Communications of the ACM</i> which showed that any program with <b>goto</b>s could be transformed into a goto-free form involving only choice (IF THEN ELSE) and loops (WHILE condition DO xxx), possibly with duplicated code and/or the addition of Boolean variables (true/false flags). Later authors showed that choice can be replaced by loops (and yet more Boolean variables). </p><p>That such minimalism is possible does not mean that it is necessarily desirable; computers theoretically need only <a href="/wiki/One_instruction_set_computer" class="mw-redirect" title="One instruction set computer">one machine instruction</a> (subtract one number from another and branch if the result is negative), but practical computers have dozens or even hundreds of machine instructions. </p><p>Other research showed that control structures with one entry and one exit were much easier to understand than any other form,<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">&#91;<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (July 2014)">citation needed</span></a></i>&#93;</sup> mainly because they could be used anywhere as a statement without disrupting the control flow. In other words, they were <i>composable</i>. (Later developments, such as <a href="/wiki/Non-strict_programming_language" class="mw-redirect" title="Non-strict programming language">non-strict programming languages</a> – and more recently, composable <a href="/wiki/Software_transactional_memory" title="Software transactional memory">software transactions</a> – have continued this strategy, making components of programs even more freely composable.) </p><p>Some academics took a purist approach to the Böhm–Jacopini result and argued that even instructions like <code>break</code> and <code>return</code> from the middle of loops are bad practice as they are not needed in the Böhm–Jacopini proof, and thus they advocated that all loops should have a single exit point. This purist approach is embodied in the language <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a> (designed in 1968–1969), which up to the mid-1990s was the preferred tool for teaching introductory programming in academia.<sup id="cite_ref-roberts_2-0" class="reference"><a href="#cite_note-roberts-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup> The direct application of the Böhm–Jacopini theorem may result in additional local variables being introduced in the structured chart, and may also result in some <a href="/wiki/Code_duplication" class="mw-redirect" title="Code duplication">code duplication</a>.<sup id="cite_ref-WattFindlay2004_3-0" class="reference"><a href="#cite_note-WattFindlay2004-3"><span class="cite-bracket">&#91;</span>3<span class="cite-bracket">&#93;</span></a></sup> Pascal is affected by both of these problems and according to empirical studies cited by <a href="/wiki/Eric_S._Roberts" title="Eric S. Roberts">Eric S. Roberts</a>, student programmers had difficulty formulating correct solutions in Pascal for several simple problems, including writing a function for searching an element in an array. A 1980 study by Henry Shapiro cited by Roberts found that using only the Pascal-provided control structures, the correct solution was given by only 20% of the subjects, while no subject wrote incorrect code for this problem if allowed to write a return from the middle of a loop.<sup id="cite_ref-roberts_2-1" class="reference"><a href="#cite_note-roberts-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Control_structures_in_practice">Control structures in practice</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=8" title="Edit section: Control structures in practice"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most programming languages with control structures have an initial keyword which indicates the type of control structure involved.<sup class="noprint Inline-Template" style="margin-left:0.1em; white-space:nowrap;">&#91;<i><a href="/wiki/Wikipedia:Please_clarify" title="Wikipedia:Please clarify"><span title="The text near this tag may need clarification or removal of jargon. (November 2015)">clarification needed</span></a></i>&#93;</sup> Languages then divide as to whether or not control structures have a final keyword. </p> <ul><li>No final keyword: <a href="/wiki/ALGOL_60" title="ALGOL 60">ALGOL 60</a>, <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>, <a href="/wiki/C%2B%2B" title="C++">C++</a>, <a href="/wiki/Go_(programming_language)" title="Go (programming language)">Go</a>, <a href="/wiki/Haskell" title="Haskell">Haskell</a>, <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a>, <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>, <a href="/wiki/Perl" title="Perl">Perl</a>, <a href="/wiki/PHP" title="PHP">PHP</a>, <a href="/wiki/PL/I" title="PL/I">PL/I</a>, <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, <a href="/wiki/PowerShell" title="PowerShell">PowerShell</a>. Such languages need some way of grouping statements together: <ul><li>ALGOL 60 and Pascal: <code>begin</code> ... <code>end</code></li> <li>C, C++, Go, Java, Perl, PHP, and PowerShell: <a href="/wiki/Curly_bracket_programming_language" class="mw-redirect" title="Curly bracket programming language">curly brackets</a> <code>{</code> ... <code>}</code></li> <li>PL/I: <code>DO</code> ... <code>END</code></li> <li>Python: uses <a href="/wiki/Indent_style" class="mw-redirect" title="Indent style">indent</a> level (see <a href="/wiki/Off-side_rule" title="Off-side rule">Off-side rule</a>)</li> <li>Haskell: either <a href="/wiki/Indent_style" class="mw-redirect" title="Indent style">indent</a> level or curly brackets can be used, and they can be freely mixed</li> <li>Lua: uses <code>do</code> ... <code>end</code></li></ul></li> <li>Final keyword: <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>, <a href="/wiki/APL_(programming_language)" title="APL (programming language)">APL</a>, <a href="/wiki/ALGOL_68" title="ALGOL 68">ALGOL 68</a>, <a href="/wiki/Modula-2" title="Modula-2">Modula-2</a>, <a href="/wiki/Fortran_77" class="mw-redirect" title="Fortran 77">Fortran 77</a>, <a href="/w/index.php?title=Mythryl&amp;action=edit&amp;redlink=1" class="new" title="Mythryl (page does not exist)">Mythryl</a>, <a href="/wiki/Visual_Basic" title="Visual Basic">Visual Basic</a>. The forms of the final keyword vary: <ul><li>Ada: final keyword is <code>end</code> + <i>space</i> + initial keyword e.g., <code>if</code> ... <code>end if</code>, <code>loop</code> ... <code>end loop</code></li> <li>APL: final keyword is <code>:End</code> optionally + initial keyword, e.g., <code>:If</code> ... <code>:End</code> or <code>:If</code> ... <code>:EndIf</code>, <code>Select</code> ... <code>:End</code> or <code>:Select</code> ... <code>:EndSelect</code>, however, if adding an end condition, the end keyword becomes <code>:Until</code></li> <li>ALGOL 68, Mythryl: initial keyword spelled backwards e.g., <code>if</code> ... <code>fi</code>, <code>case</code> ... <code>esac</code></li> <li>Fortran 77: final keyword is <code>END</code> + initial keyword e.g., <code>IF</code> ... <code>ENDIF</code>, <code>DO</code> ... <code>ENDDO</code></li> <li>Modula-2: same final keyword <code>END</code> for everything</li> <li>Visual Basic: every control structure has its own keyword. <code>If</code> ... <code>End If</code>; <code>For</code> ... <code>Next</code>; <code>Do</code> ... <code>Loop</code>; <code>While</code> ... <code>Wend</code></li></ul></li></ul> <div class="mw-heading mw-heading2"><h2 id="Choice">Choice</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=9" title="Edit section: Choice"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="If-then-(else)_statements"><span id="If-then-.28else.29_statements"></span>If-then-(else) statements</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=10" title="Edit section: If-then-(else) statements"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Conditional_(computer_programming)" title="Conditional (computer programming)">Conditional (computer programming)</a></div> <p>Conditional expressions and conditional constructs are features of a <a href="/wiki/Programming_language" title="Programming language">programming language</a> that perform different computations or actions depending on whether a programmer-specified <a href="/wiki/Boolean_data_type" title="Boolean data type">Boolean</a> <i>condition</i> evaluates to true or false. </p> <ul><li><code>IF..GOTO</code>. A form found in unstructured languages, mimicking a typical machine code instruction, would jump to (GOTO) a label or line number when the condition was met.</li> <li><code>IF..THEN..(ENDIF)</code>. Rather than being restricted to a jump, any simple statement, or nested block, could follow the THEN key keyword. This a structured form.</li> <li><code>IF..THEN..ELSE..(ENDIF)</code>. As above, but with a second action to be performed if the condition is false. This is one of the most common forms, with many variations. Some require a terminal <code>ENDIF</code>, others do not. <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> and related languages do not require a terminal keyword, or a 'then', but do require parentheses around the condition.</li> <li>Conditional statements can be and often are nested inside other conditional statements. Some languages allow <code>ELSE</code> and <code>IF</code> to be combined into <code>ELSEIF</code>, avoiding the need to have a series of <code>ENDIF</code> or other final statements at the end of a compound statement.</li></ul> <table class="wikitable"> <tbody><tr> <th><a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>: </th> <th><a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>: </th></tr> <tr> <td><div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">then</span> <span class="w"> </span><span class="nb">writeln</span><span class="p">(</span><span class="err">&quot;</span><span class="n">yes</span><span class="err">&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="w"> </span><span class="nb">writeln</span><span class="p">(</span><span class="err">&quot;</span><span class="n">no</span><span class="err">&quot;</span><span class="p">)</span><span class="o">;</span> </pre></div> </td> <td><div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">if</span> <span class="n">a</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="kr">then</span> <span class="n">Put_Line</span><span class="p">(</span><span class="s">&quot;yes&quot;</span><span class="p">);</span> <span class="kr">else</span> <span class="n">Put_Line</span><span class="p">(</span><span class="s">&quot;no&quot;</span><span class="p">);</span> <span class="kr">end</span> <span class="kr">if</span><span class="p">;</span> </pre></div> </td></tr> <tr> <th><a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>: </th> <th><a href="/wiki/Shell_script" title="Shell script">Shell script</a>: </th></tr> <tr> <td><div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span> <span class="w"> </span><span class="n">puts</span><span class="p">(</span><span class="s">&quot;yes&quot;</span><span class="p">);</span> <span class="p">}</span> <span class="k">else</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">puts</span><span class="p">(</span><span class="s">&quot;no&quot;</span><span class="p">);</span> <span class="p">}</span> </pre></div> </td> <td><div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="nv">$a</span><span class="w"> </span>-gt<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="o">]</span><span class="p">;</span><span class="w"> </span><span class="k">then</span> <span class="w"> </span><span class="nb">echo</span><span class="w"> </span><span class="s2">&quot;yes&quot;</span> <span class="k">else</span> <span class="w"> </span><span class="nb">echo</span><span class="w"> </span><span class="s2">&quot;no&quot;</span> <span class="k">fi</span> </pre></div> </td></tr> <tr> <th><a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>: </th> <th><a href="/wiki/Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a>: </th></tr> <tr> <td><div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span> <span class="n">a</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;yes&quot;</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;no&quot;</span><span class="p">)</span> </pre></div> </td> <td><div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">princ</span> <span class="w"> </span><span class="p">(</span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">plusp</span><span class="w"> </span><span class="nv">a</span><span class="p">)</span> <span class="w"> </span><span class="s">&quot;yes&quot;</span> <span class="w"> </span><span class="s">&quot;no&quot;</span><span class="p">))</span> </pre></div> </td></tr></tbody></table> <p>Less common variations include: </p> <ul><li>Some languages, such as early <a href="/wiki/Fortran" title="Fortran">Fortran</a>,<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>a<span class="cite-bracket">&#93;</span></a></sup> have a <i>three-way</i> or <i><a href="/wiki/Arithmetic_if" class="mw-redirect" title="Arithmetic if">arithmetic if</a></i>, testing whether a numeric value is negative, zero, or positive.</li> <li>Some languages have a <a href="/wiki/Functional_programming" title="Functional programming">functional</a> form of an <code>if</code> statement, for instance <a href="/wiki/Lisp_(programming_language)" title="Lisp (programming language)">Lisp's</a> <code>cond</code>.</li> <li>Some languages have an <a href="/wiki/Operator_(programming)" class="mw-redirect" title="Operator (programming)">operator</a> form of an <code>if</code> statement, such as C's <a href="/wiki/Ternary_operator" class="mw-redirect" title="Ternary operator">ternary operator</a>.</li> <li><a href="/wiki/Perl" title="Perl">Perl</a> supplements a C-style <code>if</code> with <code>when</code> and <code>unless</code>.</li> <li><a href="/wiki/Smalltalk" title="Smalltalk">Smalltalk</a> uses <code>ifTrue</code> and <code>ifFalse</code> messages to implement conditionals, rather than any fundamental language construct.</li></ul> <div class="mw-heading mw-heading3"><h3 id="Case_and_switch_statements">Case and switch statements</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=11" title="Edit section: Case and switch statements"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Switch_statement" title="Switch statement">Switch statement</a></div> <p><a href="/wiki/Switch_statement" title="Switch statement">Switch statements</a> (or <i>case statements</i>, or <i>multiway branches</i>) compare a given value with specified constants and take action according to the first constant to match. There is usually a provision for a default action ("else", "otherwise") to be taken if no match succeeds. Switch statements can allow compiler optimizations, such as <a href="/wiki/Lookup_table" title="Lookup table">lookup tables</a>. In <a href="/wiki/Dynamic_language" class="mw-redirect" title="Dynamic language">dynamic languages</a>, the cases may not be limited to constant expressions, and might extend to <a href="/wiki/Pattern_matching" title="Pattern matching">pattern matching</a>, as in the <a href="/wiki/Shell_script" title="Shell script">shell script</a> example on the right, where the <code>*)</code> implements the default case as a <a href="/wiki/Glob_(programming)" title="Glob (programming)">glob</a> matching any string. Case logic can also be implemented in functional form, as in <a href="/wiki/SQL" title="SQL">SQL</a>'s <code>decode</code> statement. </p> <table class="wikitable"> <tbody><tr> <th><a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>: </th> <th><a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>: </th></tr> <tr> <td><div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span></span><span class="k">case</span><span class="w"> </span><span class="n">someChar</span><span class="w"> </span><span class="k">of</span> <span class="w"> </span><span class="s">&#39;a&#39;</span><span class="o">:</span><span class="w"> </span><span class="n">actionOnA</span><span class="o">;</span> <span class="w"> </span><span class="s">&#39;x&#39;</span><span class="o">:</span><span class="w"> </span><span class="n">actionOnX</span><span class="o">;</span> <span class="w"> </span><span class="s">&#39;y&#39;</span><span class="o">,</span><span class="s">&#39;z&#39;</span><span class="o">:</span><span class="n">actionOnYandZ</span><span class="o">;</span> <span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">actionOnNoMatch</span><span class="o">;</span> <span class="k">end</span><span class="o">;</span> </pre></div> </td> <td><div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">case</span> <span class="n">someChar</span> <span class="kr">is</span> <span class="kr">when</span> <span class="p">&#39;</span><span class="na">a</span><span class="p">&#39;</span> <span class="p">=&gt;</span> <span class="n">actionOnA</span><span class="p">;</span> <span class="kr">when</span> <span class="p">&#39;</span><span class="na">x</span><span class="p">&#39;</span> <span class="p">=&gt;</span> <span class="n">actionOnX</span><span class="p">;</span> <span class="kr">when</span> <span class="p">&#39;</span><span class="na">y</span><span class="p">&#39;</span> <span class="p">|</span> <span class="p">&#39;</span><span class="na">z</span><span class="p">&#39;</span> <span class="p">=&gt;</span> <span class="n">actionOnYandZ</span><span class="p">;</span> <span class="kr">when</span> <span class="kr">others</span> <span class="p">=&gt;</span> <span class="n">actionOnNoMatch</span><span class="p">;</span> <span class="kr">end</span><span class="p">;</span> </pre></div> </td></tr> <tr> <th><a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>: </th> <th><a href="/wiki/Shell_script" title="Shell script">Shell script</a>: </th></tr> <tr> <td><div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="k">switch</span><span class="w"> </span><span class="p">(</span><span class="n">someChar</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="sc">&#39;a&#39;</span><span class="p">:</span><span class="w"> </span><span class="n">actionOnA</span><span class="p">;</span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="sc">&#39;x&#39;</span><span class="p">:</span><span class="w"> </span><span class="n">actionOnX</span><span class="p">;</span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="sc">&#39;y&#39;</span><span class="p">:</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="sc">&#39;z&#39;</span><span class="p">:</span><span class="w"> </span><span class="n">actionOnYandZ</span><span class="p">;</span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="w"> </span><span class="k">default</span><span class="o">:</span><span class="w"> </span><span class="n">actionOnNoMatch</span><span class="p">;</span> <span class="p">}</span> </pre></div> </td> <td><div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span><span class="k">case</span><span class="w"> </span><span class="nv">$someChar</span><span class="w"> </span><span class="k">in</span><span class="w"> </span> <span class="w"> </span>a<span class="o">)</span><span class="w"> </span>actionOnA<span class="w"> </span><span class="p">;;</span> <span class="w"> </span>x<span class="o">)</span><span class="w"> </span>actionOnX<span class="w"> </span><span class="p">;;</span> <span class="w"> </span><span class="o">[</span>yz<span class="o">])</span><span class="w"> </span>actionOnYandZ<span class="w"> </span><span class="p">;;</span> <span class="w"> </span>*<span class="o">)</span><span class="w"> </span>actionOnNoMatch<span class="w"> </span><span class="p">;;</span> <span class="k">esac</span> </pre></div> </td></tr> <tr> <th><a href="/wiki/Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a>: </th> <th><a href="/wiki/Fortran" title="Fortran">Fortran</a>: </th></tr> <tr> <td><div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">case</span><span class="w"> </span><span class="nv">some-char</span> <span class="w"> </span><span class="p">((</span><span class="sc">#\a</span><span class="p">)</span><span class="w"> </span><span class="nv">action-on-a</span><span class="p">)</span> <span class="w"> </span><span class="p">((</span><span class="sc">#\x</span><span class="p">)</span><span class="w"> </span><span class="nv">action-on-x</span><span class="p">)</span> <span class="w"> </span><span class="p">((</span><span class="sc">#\y</span><span class="w"> </span><span class="sc">#\z</span><span class="p">)</span><span class="w"> </span><span class="nv">action-on-y-and-z</span><span class="p">)</span> <span class="w"> </span><span class="p">(</span><span class="nv">else</span><span class="w"> </span><span class="nv">action-on-no-match</span><span class="p">))</span> </pre></div> </td> <td><div class="mw-highlight mw-highlight-lang-fortran mw-content-ltr" dir="ltr"><pre><span></span><span class="k">select case</span><span class="w"> </span><span class="p">(</span><span class="n">someChar</span><span class="p">)</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;a&#39;</span><span class="p">)</span> <span class="w"> </span><span class="n">actionOnA</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span> <span class="w"> </span><span class="n">actionOnX</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;y&#39;</span><span class="p">,</span><span class="s1">&#39;z&#39;</span><span class="p">)</span> <span class="w"> </span><span class="n">actionOnYandZ</span> <span class="w"> </span><span class="k">case </span><span class="n">default</span> <span class="w"> </span><span class="n">actionOnNoMatch</span> <span class="k">end select</span> </pre></div> </td></tr></tbody></table> <div class="mw-heading mw-heading2"><h2 id="Loops">Loops</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=12" title="Edit section: Loops"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A loop is a sequence of statements which is specified once but which may be carried out several times in succession. The code "inside" the loop (the <i>body</i> of the loop, shown below as <i>xxx</i>) is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met, or <a href="/wiki/Infinite_loop" title="Infinite loop">indefinitely</a>. When one of those items is itself also a loop, it is called a "nested loop".<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">&#91;</span>4<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">&#91;</span>5<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">&#91;</span>6<span class="cite-bracket">&#93;</span></a></sup> </p><p>In <a href="/wiki/Functional_programming" title="Functional programming">functional programming</a> languages, such as <a href="/wiki/Haskell" title="Haskell">Haskell</a> and <a href="/wiki/Scheme_(programming_language)" title="Scheme (programming language)">Scheme</a>, both <a href="/wiki/Recursion_(computer_science)" title="Recursion (computer science)">recursive</a> and <a href="/wiki/Fixed_point_combinator" class="mw-redirect" title="Fixed point combinator">iterative</a> processes are expressed with <a href="/wiki/Tail_recursion" class="mw-redirect" title="Tail recursion">tail recursive</a> procedures instead of looping constructs that are syntactic. </p> <div class="mw-heading mw-heading3"><h3 id="Count-controlled_loops">Count-controlled loops</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=13" title="Edit section: Count-controlled loops"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/For_loop" title="For loop">For loop</a></div> <p>Most programming languages have constructions for repeating a loop a certain number of times. In most cases counting can go downwards instead of upwards and step sizes other than 1 can be used. </p> <table class="wikitable"> <tbody><tr> <td> <pre>FOR I = 1 TO N xxx NEXT I </pre> </td> <td> <pre><b>for</b> I&#160;:= 1 <b>to</b> N <b>do</b> <b>begin</b> xxx <b>end</b>; </pre> </td></tr> <tr> <td> <pre>DO I = 1,N xxx END DO </pre> </td> <td> <pre><b>for</b> ( I=1; I&lt;=N; ++I ) { xxx } </pre> </td></tr></tbody></table> <p>In these examples, if N &lt; 1 then the body of loop may execute once (with I having value 1) or not at all, depending on the programming language. </p><p>In many programming languages, only integers can be reliably used in a count-controlled loop. Floating-point numbers are represented imprecisely due to hardware constraints, so a loop such as<br /> </p> <pre> <b>for</b> X&#160;:= 0.1 <b>step</b> 0.1 <b>to</b> 1.0 <b>do</b> </pre> <p>might be repeated 9 or 10 times, depending on rounding errors and/or the hardware and/or the compiler version. Furthermore, if the increment of X occurs by repeated addition, accumulated rounding errors may mean that the value of X in each iteration can differ quite significantly from the expected sequence 0.1, 0.2, 0.3, ..., 1.0. </p> <div class="mw-heading mw-heading3"><h3 id="Condition-controlled_loops">Condition-controlled loops</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=14" title="Edit section: Condition-controlled loops"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main articles: <a href="/wiki/While_loop" title="While loop">While loop</a> and <a href="/wiki/Do_while_loop" title="Do while loop">Do while loop</a></div> <p>Most programming languages have constructions for repeating a loop until some condition changes. Some variations test the condition at the start of the loop; others test it at the end. If the test is at the start, the body may be skipped completely; if it is at the end, the body is always executed at least once. </p> <table class="wikitable"> <tbody><tr> <td> <pre>DO WHILE (test) xxx LOOP </pre> </td> <td> <pre><b>repeat</b> xxx <b>until</b> test; </pre> </td></tr> <tr> <td> <pre><b>while</b> (test) { xxx } </pre> </td> <td> <pre><b>do</b> xxx <b>while</b> (test); </pre> </td></tr></tbody></table> <p>A <a href="/wiki/Control_break" title="Control break">control break</a> is a value change detection method used within ordinary loops to trigger processing for groups of values. Values are monitored within the loop and a change diverts program flow to the handling of the group event associated with them. </p> <pre> DO UNTIL (End-of-File) IF new-zipcode &lt;&gt; current-zipcode display_tally(current-zipcode, zipcount) current-zipcode = new-zipcode zipcount = 0 ENDIF zipcount++ LOOP </pre> <div class="mw-heading mw-heading3"><h3 id="Collection-controlled_loops">Collection-controlled loops</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=15" title="Edit section: Collection-controlled loops"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Foreach_loop" title="Foreach loop">Foreach</a></div> <p>Several programming languages (e.g., <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>, <a href="/wiki/D_(programming_language)" title="D (programming language)">D</a>, <a href="/wiki/C%2B%2B11" title="C++11">C++11</a>, <a href="/wiki/Smalltalk" title="Smalltalk">Smalltalk</a>, <a href="/wiki/PHP" title="PHP">PHP</a>, <a href="/wiki/Perl" title="Perl">Perl</a>, <a href="/wiki/Object_Pascal" title="Object Pascal">Object Pascal</a>, <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a>, <a href="/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a>, <a href="/wiki/MATLAB" title="MATLAB">MATLAB</a>, <a href="/wiki/Visual_Basic" title="Visual Basic">Visual Basic</a>, <a href="/wiki/Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a>, <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, <a href="/wiki/JavaScript" title="JavaScript">JavaScript</a>, <a href="/wiki/Fortran_95" class="mw-redirect" title="Fortran 95">Fortran 95</a> and later) have special constructs which allow implicit looping through all elements of an array, or all members of a set or collection. </p> <pre> someCollection <b>do</b>: [:eachElement |xxx]. <b>for</b> Item <b>in</b> Collection <b>do</b> <b>begin</b> xxx <b>end</b>; <b>foreach</b> (item; myCollection) { xxx } <b>foreach</b> someArray { xxx } <b>foreach</b> ($someArray as $k =&gt; $v) { xxx } Collection&lt;String&gt; coll; <b>for</b> (String s&#160;: coll) {} <b>foreach</b> (<b>string</b> s <b>in</b> myStringCollection) { xxx } someCollection | ForEach-Object { $_ } <b>forall</b> ( index = first:last:step... ) </pre> <p><a href="/wiki/Scala_(programming_language)" title="Scala (programming language)">Scala</a> has <a href="/wiki/Scala_(programming_language)#For-expressions" title="Scala (programming language)">for-expressions</a>, which generalise collection-controlled loops, and also support other uses, such as <a href="/wiki/Asynchronous_programming" class="mw-redirect" title="Asynchronous programming">asynchronous programming</a>. <a href="/wiki/Haskell" title="Haskell">Haskell</a> has do-expressions and comprehensions, which together provide similar function to for-expressions in Scala. </p> <div class="mw-heading mw-heading3"><h3 id="General_iteration">General iteration</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=16" title="Edit section: General iteration"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>General iteration constructs such as C's <code>for</code> statement and <a href="/wiki/Common_Lisp" title="Common Lisp">Common Lisp</a>'s <code>do</code> form can be used to express any of the above sorts of loops, and others, such as looping over some number of collections in parallel. Where a more specific looping construct can be used, it is usually preferred over the general iteration construct, since it often makes the purpose of the expression clearer. </p> <div class="mw-heading mw-heading3"><h3 id="Infinite_loops">Infinite loops</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=17" title="Edit section: Infinite loops"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Infinite_loop" title="Infinite loop">Infinite loop</a></div> <p><a href="/wiki/Infinite_loop" title="Infinite loop">Infinite loops</a> are used to assure a program segment loops forever or until an exceptional condition arises, such as an error. For instance, an event-driven program (such as a <a href="/wiki/Server_(computing)" title="Server (computing)">server</a>) should loop forever, handling events as they occur, only stopping when the process is terminated by an operator. </p><p>Infinite loops can be implemented using other control flow constructs. Most commonly, in unstructured programming this is jump back up (goto), while in structured programming this is an indefinite loop (while loop) set to never end, either by omitting the condition or explicitly setting it to true, as <code>while (true) ...</code>. Some languages have special constructs for infinite loops, typically by omitting the condition from an indefinite loop. Examples include Ada (<code>loop ... end loop</code>),<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">&#91;</span>7<span class="cite-bracket">&#93;</span></a></sup> Fortran (<code>DO ... END DO</code>), Go (<code>for { ... }</code>), and Ruby (<code>loop do ... end</code>). </p><p>Often, an infinite loop is unintentionally created by a programming error in a condition-controlled loop, wherein the loop condition uses variables that never change within the loop. </p> <div class="mw-heading mw-heading3"><h3 id="Continuation_with_next_iteration">Continuation with next iteration</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=18" title="Edit section: Continuation with next iteration"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Sometimes within the body of a loop there is a desire to skip the remainder of the loop body and continue with the next iteration of the loop. Some languages provide a statement such as <code>continue</code> (most languages), <code>skip</code>,<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup> <code>cycle</code> (Fortran), or <code>next</code> (Perl and Ruby), which will do this. The effect is to prematurely terminate the innermost loop body and then resume as normal with the next iteration. If the iteration is the last one in the loop, the effect is to terminate the entire loop early. </p> <div class="mw-heading mw-heading3"><h3 id="Redo_current_iteration">Redo current iteration</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=19" title="Edit section: Redo current iteration"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some languages, like Perl<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">&#91;</span>9<span class="cite-bracket">&#93;</span></a></sup> and Ruby,<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">&#91;</span>10<span class="cite-bracket">&#93;</span></a></sup> have a <code>redo</code> statement that restarts the current iteration from the start. </p> <div class="mw-heading mw-heading3"><h3 id="Restart_loop">Restart loop</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=20" title="Edit section: Restart loop"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Ruby has a <code>retry</code> statement that restarts the entire loop from the initial iteration.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">&#91;</span>11<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Early_exit_from_loops">Early exit from loops</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=21" title="Edit section: Early exit from loops"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>When using a count-controlled loop to search through a table, it might be desirable to stop searching as soon as the required item is found. Some programming languages provide a statement such as <code>break</code> (most languages), <code>Exit</code> (Visual Basic), or <code>last</code> (Perl), which effect is to terminate the current loop immediately, and transfer control to the statement immediately after that loop. Another term for early-exit loops is <a href="/wiki/Loop-and-a-half" class="mw-redirect" title="Loop-and-a-half">loop-and-a-half</a>. </p><p>The following example is done in <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a> which supports both <i>early exit from loops</i> and <i><a class="mw-selflink-fragment" href="#Loop_with_test_in_the_middle">loops with test in the middle</a></i>. Both features are very similar and comparing both code snippets will show the difference: <i>early exit</i> must be combined with an <b>if</b> statement while a <i>condition in the middle</i> is a self-contained construct. </p> <div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">with</span> <span class="n">Ada.Text</span> <span class="n">IO</span><span class="p">;</span> <span class="kn">with</span> <span class="n">Ada.Integer</span> <span class="n">Text</span> <span class="n">IO</span><span class="p">;</span> <span class="kd">procedure</span> <span class="nf">Print_Squares</span> <span class="kr">is</span> <span class="n">X</span> <span class="p">:</span> <span class="kt">Integer</span><span class="p">;</span> <span class="kr">begin</span> <span class="nl">Read_Data</span> <span class="p">:</span> <span class="kr">loop</span> <span class="n">Ada</span><span class="p">.</span><span class="kt">Integer</span> <span class="n">Text</span> <span class="n">IO</span><span class="p">.</span><span class="n">Get</span><span class="p">(</span><span class="n">X</span><span class="p">);</span> <span class="kr">exit</span> <span class="n">Read_Data</span> <span class="kr">when</span> <span class="n">X</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Text</span> <span class="n">IO</span><span class="p">.</span><span class="n">Put</span> <span class="p">(</span><span class="n">X</span> <span class="o">*</span> <span class="n">X</span><span class="p">);</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Text</span> <span class="n">IO</span><span class="p">.</span><span class="n">New_Line</span><span class="p">;</span> <span class="kr">end</span> <span class="kr">loop</span> <span class="nf">Read_Data</span><span class="p">;</span> <span class="kr">end</span> <span class="nf">Print_Squares</span><span class="p">;</span> </pre></div> <p><a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a> supports conditional execution of code depending on whether a loop was exited early (with a <code>break</code> statement) or not by using an else-clause with the loop. For example, </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">set_of_numbers</span><span class="p">:</span> <span class="k">if</span> <span class="n">isprime</span><span class="p">(</span><span class="n">n</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Set contains a prime number&quot;</span><span class="p">)</span> <span class="k">break</span> <span class="k">else</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Set did not contain any prime numbers&quot;</span><span class="p">)</span> </pre></div> <p>The <code>else</code> clause in the above example is linked to the <code>for</code> statement, and not the inner <code>if</code> statement. Both Python's <code>for</code> and <code>while</code> loops support such an else clause, which is executed only if early exit of the loop has not occurred. </p><p>Some languages support breaking out of nested loops; in theory circles, these are called multi-level breaks. One common use example is searching a multi-dimensional table. This can be done either via multilevel breaks (break out of <i>N</i> levels), as in bash<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">&#91;</span>12<span class="cite-bracket">&#93;</span></a></sup> and PHP,<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">&#91;</span>13<span class="cite-bracket">&#93;</span></a></sup> or via labeled breaks (break out and continue at given label), as in Go, Java and Perl.<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">&#91;</span>14<span class="cite-bracket">&#93;</span></a></sup> Alternatives to multilevel breaks include single breaks, together with a state variable which is tested to break out another level; exceptions, which are caught at the level being broken out to; placing the nested loops in a function and using return to effect termination of the entire nested loop; or using a label and a goto statement. C does not include a multilevel break, and the usual alternative is to use a goto to implement a labeled break.<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">&#91;</span>15<span class="cite-bracket">&#93;</span></a></sup> Python does not have a multilevel break or continue – this was proposed in <a rel="nofollow" class="external text" href="https://www.python.org/dev/peps/pep-3136/">PEP 3136</a>, and rejected on the basis that the added complexity was not worth the rare legitimate use.<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">&#91;</span>16<span class="cite-bracket">&#93;</span></a></sup> </p><p>The notion of multi-level breaks is of some interest in <a href="/wiki/Theoretical_computer_science" title="Theoretical computer science">theoretical computer science</a>, because it gives rise to what is today called the <i>Kosaraju hierarchy</i>.<sup id="cite_ref-kozen_18-0" class="reference"><a href="#cite_note-kozen-18"><span class="cite-bracket">&#91;</span>17<span class="cite-bracket">&#93;</span></a></sup> In 1973 <a href="/wiki/S._Rao_Kosaraju" title="S. Rao Kosaraju">S. Rao Kosaraju</a> refined the <a href="/wiki/Structured_program_theorem" title="Structured program theorem">structured program theorem</a> by proving that it is possible to avoid adding additional variables in structured programming, as long as arbitrary-depth, multi-level breaks from loops are allowed.<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">&#91;</span>18<span class="cite-bracket">&#93;</span></a></sup> Furthermore, Kosaraju proved that a strict hierarchy of programs exists: for every integer <i>n</i>, there exists a program containing a multi-level break of depth <i>n</i> that cannot be rewritten as a program with multi-level breaks of depth less than <i>n</i> without introducing added variables.<sup id="cite_ref-kozen_18-1" class="reference"><a href="#cite_note-kozen-18"><span class="cite-bracket">&#91;</span>17<span class="cite-bracket">&#93;</span></a></sup> </p><p>One can also <code>return</code> out of a subroutine executing the looped statements, breaking out of both the nested loop and the subroutine. There are other <a href="#Proposed_control_structures">proposed control structures</a> for multiple breaks, but these are generally implemented as exceptions instead. </p><p>In his 2004 textbook, <a href="/wiki/David_Watt_(computer_scientist)" title="David Watt (computer scientist)">David Watt</a> uses Tennent's notion of <a href="/wiki/S-algol" title="S-algol">sequencer</a> to explain the similarity between multi-level breaks and return statements. Watt notes that a class of sequencers known as <i>escape sequencers</i>, defined as "sequencer that terminates execution of a textually enclosing command or procedure", encompasses both breaks from loops (including multi-level breaks) and return statements. As commonly implemented, however, return sequencers may also carry a (return) value, whereas the break sequencer as implemented in contemporary languages usually cannot.<sup id="cite_ref-WattFindlay2004b_20-0" class="reference"><a href="#cite_note-WattFindlay2004b-20"><span class="cite-bracket">&#91;</span>19<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Loop_variants_and_invariants">Loop variants and invariants</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=22" title="Edit section: Loop variants and invariants"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Loop_variant" title="Loop variant">Loop variants</a> and <a href="/wiki/Loop_invariant" title="Loop invariant">loop invariants</a> are used to express correctness of loops.<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">&#91;</span>20<span class="cite-bracket">&#93;</span></a></sup> </p><p>In practical terms, a loop variant is an integer expression which has an initial non-negative value. The variant's value must decrease during each loop iteration but must never become negative during the correct execution of the loop. Loop variants are used to guarantee that loops will terminate. </p><p>A loop invariant is an assertion which must be true before the first loop iteration and remain true after each iteration. This implies that when a loop terminates correctly, both the exit condition and the loop invariant are satisfied. Loop invariants are used to monitor specific properties of a loop during successive iterations. </p><p>Some programming languages, such as <a href="/wiki/Eiffel_(programming_language)" title="Eiffel (programming language)">Eiffel</a> contain native support for loop variants and invariants. In other cases, support is an add-on, such as the <a href="/wiki/Java_Modeling_Language" title="Java Modeling Language">Java Modeling Language</a>'s specification for <a rel="nofollow" class="external text" href="http://www.eecs.ucf.edu/~leavens/JML//jmlrefman/jmlrefman_12.html#SEC168">loop statements</a> in <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Loop_sublanguage">Loop sublanguage</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=23" title="Edit section: Loop sublanguage"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some <a href="/wiki/Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a> dialects provide an extensive sublanguage for describing Loops. An early example can be found in Conversional Lisp of <a href="/wiki/Interlisp" title="Interlisp">Interlisp</a>. <a href="/wiki/Common_Lisp" title="Common Lisp">Common Lisp</a><sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">&#91;</span>21<span class="cite-bracket">&#93;</span></a></sup> provides a Loop macro which implements such a sublanguage. </p> <div class="mw-heading mw-heading3"><h3 id="Loop_system_cross-reference_table">Loop system cross-reference table</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=24" title="Edit section: Loop system cross-reference table"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <table class="wikitable"> <tbody><tr> <th rowspan="2"><a href="/wiki/Programming_language" title="Programming language">Programming language</a> </th> <th colspan="3">conditional </th> <th colspan="4">loop </th> <th rowspan="2">early exit </th> <th rowspan="2">loop continuation </th> <th rowspan="2">redo </th> <th rowspan="2">retry </th> <th colspan="2">correctness facilities </th></tr> <tr> <th>begin </th> <th>middle </th> <th>end </th> <th>count </th> <th>collection </th> <th>general </th> <th>infinite <style data-mw-deduplicate="TemplateStyles:r1041539562">.mw-parser-output .citation{word-wrap:break-word}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}</style><sup class="citation nobold" id="ref_loop_infinitea"><a href="#endnote_loop_infinitea">[1]</a></sup> </th> <th>variant </th> <th>invariant </th></tr> <tr> <td><a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">arrays </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/APL_(programming_language)" title="APL (programming language)">APL</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ca"><a href="#endnote_deep_break_ca">[3]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_fora"><a href="#endnote_loop_fora">[2]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ca"><a href="#endnote_deep_break_ca">[3]</a></sup> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ca"><a href="#endnote_deep_break_ca">[3]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/C%2B%2B" title="C++">C++</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_forb"><a href="#endnote_loop_forb">[2]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_foreacha"><a href="#endnote_loop_foreacha">[9]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_cb"><a href="#endnote_deep_break_cb">[3]</a></sup> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ca"><a href="#endnote_deep_break_ca">[3]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_forc"><a href="#endnote_loop_forc">[2]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_cc"><a href="#endnote_deep_break_cc">[3]</a></sup> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ca"><a href="#endnote_deep_break_ca">[3]</a></sup> </td> <td> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/COBOL" title="COBOL">COBOL</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_cobol_deep_exita"><a href="#endnote_cobol_deep_exita">[15]</a></sup> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_cobol_deep_exita"><a href="#endnote_cobol_deep_exita">[14]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Common_Lisp" title="Common Lisp">Common Lisp</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">builtin only <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_cl_sequence_typea"><a href="#endnote_cl_sequence_typea">[16]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/D_(programming_language)" title="D (programming language)">D</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_DInfinitea"><a href="#endnote_DInfinitea">[14]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Eiffel_(programming_language)" title="Eiffel (programming language)">Eiffel</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_count_loop_eiffela"><a href="#endnote_count_loop_eiffela">[10]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">one level <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_count_loop_eiffela"><a href="#endnote_count_loop_eiffela">[10]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_retry_in_eiffela"><a href="#endnote_retry_in_eiffela">[11]</a></sup> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">integer only <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_integer_varianta"><a href="#endnote_integer_varianta">[13]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td></tr> <tr> <td><a href="/wiki/F_Sharp_(programming_language)" title="F Sharp (programming language)">F#</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_eb"><a href="#endnote_deep_break_eb">[6]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/FORTRAN_77" class="mw-redirect" title="FORTRAN 77">FORTRAN 77</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">one level </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Fortran_90" class="mw-redirect" title="Fortran 90">Fortran 90</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Fortran_95" class="mw-redirect" title="Fortran 95">Fortran 95</a> and later </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">arrays </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Go_(programming_language)" title="Go (programming language)">Go</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">builtin only </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Haskell" title="Haskell">Haskell</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ea"><a href="#endnote_deep_break_ea">[6]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_ford"><a href="#endnote_loop_ford">[2]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">non-native <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_requires_JMLa"><a href="#endnote_requires_JMLa">[12]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">non-native <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_requires_JMLa"><a href="#endnote_requires_JMLa">[12]</a></sup> </td></tr> <tr> <td><a href="/wiki/JavaScript" title="JavaScript">JavaScript</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_forg"><a href="#endnote_loop_forg">[2]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td></tr> <tr> <td>Natural </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td></tr> <tr> <td><a href="/wiki/OCaml" title="OCaml">OCaml</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">arrays,lists </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_eb"><a href="#endnote_deep_break_eb">[6]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/PHP" title="PHP">PHP</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_fore"><a href="#endnote_loop_fore">[2]</a></sup> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_forb"><a href="#endnote_loop_forb">[5]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_phpforeacha"><a href="#endnote_loop_phpforeacha">[4]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Perl" title="Perl">Perl</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_forf"><a href="#endnote_loop_forf">[2]</a></sup> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_forc"><a href="#endnote_loop_forc">[5]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">deep nested </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_rangea"><a href="#endnote_loop_rangea">[5]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ec"><a href="#endnote_deep_break_ec">[6]</a></sup> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ec"><a href="#endnote_deep_break_ec">[6]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Rebol" title="Rebol">Rebol</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_whilea"><a href="#endnote_whilea">[7]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_usera"><a href="#endnote_usera">[8]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">one level <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ed"><a href="#endnote_deep_break_ed">[6]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ee"><a href="#endnote_deep_break_ee">[6]</a></sup> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">deep nested <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_ee"><a href="#endnote_deep_break_ee">[6]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Standard_ML" title="Standard ML">Standard ML</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">arrays,lists </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_deep_break_eb"><a href="#endnote_deep_break_eb">[6]</a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/Visual_Basic_.NET" class="mw-redirect" title="Visual Basic .NET">Visual Basic .NET</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">one level per type of loop </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">one level per type of loop </td> <td> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td><a href="/wiki/PowerShell" title="PowerShell">PowerShell</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><sup class="citation nobold" id="ref_loop_forh"><a href="#endnote_loop_forh">[2]</a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td> </td> <td> </td> <td> </td> <td> </td></tr></tbody></table> <ol><li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_infinitea"><a href="#ref_loop_infinitea"><b><sup>a</sup></b></a></span> <code>while (true)</code> does not count as an infinite loop for this purpose, because it is not a dedicated language structure.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_fora"><a href="#ref_loop_fora"><b><sup>a</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_forb"><a href="#ref_loop_forb"><b><sup>b</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_forc"><a href="#ref_loop_forc"><b><sup>c</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_ford"><a href="#ref_loop_ford"><b><sup>d</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_fore"><a href="#ref_loop_fore"><b><sup>e</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_forf"><a href="#ref_loop_forf"><b><sup>f</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_forg"><a href="#ref_loop_forg"><b><sup>g</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_forh"><a href="#ref_loop_forh"><b><sup>h</sup></b></a></span> C's <code>for (<i>init</i>; <i>test</i>; <i>increment</i>)</code> loop is a general loop construct, not specifically a counting one, although it is often used for that.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_ca"><a href="#ref_deep_break_ca"><b><sup>a</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_cb"><a href="#ref_deep_break_cb"><b><sup>b</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_cc"><a href="#ref_deep_break_cc"><b><sup>c</sup></b></a></span> Deep breaks may be accomplished in APL, C, C++ and C# through the use of labels and gotos.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_phpforeacha"><a href="#ref_loop_phpforeacha"><b><sup>a</sup></b></a></span> Iteration over objects was <a rel="nofollow" class="external text" href="http://www.php.net/manual/en/language.oop5.iterations.php">added</a> in PHP 5.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_rangea"><a href="#ref_loop_rangea"><b><sup>a</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_rangeb"><a href="#ref_loop_rangeb"><b><sup>b</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_rangec"><a href="#ref_loop_rangec"><b><sup>c</sup></b></a></span> A counting loop can be simulated by iterating over an incrementing list or generator, for instance, Python's <code>range()</code>.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_ea"><a href="#ref_deep_break_ea"><b><sup>a</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_eb"><a href="#ref_deep_break_eb"><b><sup>b</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_ec"><a href="#ref_deep_break_ec"><b><sup>c</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_ed"><a href="#ref_deep_break_ed"><b><sup>d</sup></b></a></span> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_deep_break_ee"><a href="#ref_deep_break_ee"><b><sup>e</sup></b></a></span> Deep breaks may be accomplished through the use of exception handling.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_whilea"><a href="#ref_whilea"><b><sup>a</sup></b></a></span> There is no special construct, since the <code>while</code> function can be used for this.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_usera"><a href="#ref_usera"><b><sup>a</sup></b></a></span> There is no special construct, but users can define general loop functions.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_loop_foreacha"><a href="#ref_loop_foreacha"><b><sup>a</sup></b></a></span> The <a href="/wiki/C%2B%2B11" title="C++11">C++11</a> standard introduced the <a href="/wiki/C%2B%2B11#Range-based_for_loop" title="C++11">range-based for</a>. In the <a href="/wiki/Standard_Template_Library" title="Standard Template Library">STL</a>, there is a <code>std::for_each</code> <a href="/wiki/Template_(programming)" class="mw-redirect" title="Template (programming)">template</a> function which can iterate on STL <a href="/wiki/Container_(data_structure)" class="mw-redirect" title="Container (data structure)">containers</a> and call a <a href="/wiki/Unary_function" title="Unary function">unary function</a> for each element.<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">&#91;</span>22<span class="cite-bracket">&#93;</span></a></sup> The functionality also can be constructed as <a href="/wiki/C_preprocessor#Macro_definition_and_expansion" title="C preprocessor">macro</a> on these containers.<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">&#91;</span>23<span class="cite-bracket">&#93;</span></a></sup></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_count_loop_eiffela"><a href="#ref_count_loop_eiffela"><b><sup>a</sup></b></a></span> Count-controlled looping is effected by iteration across an integer interval; early exit by including an additional condition for exit.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_retry_in_eiffela"><a href="#ref_retry_in_eiffela"><b><sup>a</sup></b></a></span> Eiffel supports a reserved word <code>retry</code>, however it is used in <a href="/wiki/Exception_handling#Exception_handling_based_on_design_by_contract" title="Exception handling">exception handling</a>, not loop control.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_requires_JMLa"><a href="#ref_requires_JMLa"><b><sup>a</sup></b></a></span> Requires <a href="/wiki/Java_Modeling_Language" title="Java Modeling Language">Java Modeling Language</a> (JML) behavioral interface specification language.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_integer_varianta"><a href="#ref_integer_varianta"><b><sup>a</sup></b></a></span> Requires loop variants to be integers; transfinite variants are not supported. <a rel="nofollow" class="external autonumber" href="http://archive.eiffel.com/doc/faq/variant.html">[1]</a></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_DInfinitea"><a href="#ref_DInfinitea"><b><sup>a</sup></b></a></span> D supports infinite collections, and the ability to iterate over those collections. This does not require any special construct.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_cobol_deep_exita"><a href="#ref_cobol_deep_exita"><b><sup>a</sup></b></a></span> Deep breaks can be achieved using <code>GO TO</code> and procedures.</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1041539562" /><span class="citation wikicite" id="endnote_cl_sequence_typea"><a href="#ref_cl_sequence_typea"><b><sup>a</sup></b></a></span> Common Lisp predates the concept of generic collection type.</li></ol> <div class="mw-heading mw-heading2"><h2 id="Structured_non-local_control_flow">Structured non-local control flow</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=25" title="Edit section: Structured non-local control flow"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Many programming languages, especially those favoring more dynamic styles of programming, offer constructs for <i>non-local control flow</i>. These cause the flow of execution to jump out of a given context and resume at some <a href="/wiki/Predeclared" title="Predeclared">predeclared</a> point. <i><a href="/wiki/Exception_handling#Condition_systems" title="Exception handling">Conditions</a></i>, <i><a href="/wiki/Exception_handling" title="Exception handling">exceptions</a></i> and <i><a href="/wiki/Continuation" title="Continuation">continuations</a></i> are three common sorts of non-local control constructs; more exotic ones also exist, such as <a href="/wiki/Generator_(computer_programming)" title="Generator (computer programming)">generators</a>, <a href="/wiki/Coroutine" title="Coroutine">coroutines</a> and the <a href="/wiki/Futures_and_promises" title="Futures and promises">async</a> keyword. </p> <div class="mw-heading mw-heading3"><h3 id="Conditions">Conditions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=26" title="Edit section: Conditions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The earliest <a href="/wiki/Fortran" title="Fortran">Fortran</a> compilers had statements for testing exceptional conditions. These included the <code>IF ACCUMULATOR OVERFLOW</code>, <code>IF QUOTIENT OVERFLOW</code>, and <code>IF DIVIDE CHECK</code> statements. In the interest of machine independence, they were not included in FORTRAN IV and the Fortran 66 Standard. However since Fortran 2003 it is possible to test for numerical issues via calls to functions in the <code>IEEE_EXCEPTIONS</code> module. </p><p><a href="/wiki/PL/I" title="PL/I">PL/I</a> has some 22 standard conditions (e.g., ZERODIVIDE SUBSCRIPTRANGE ENDFILE) which can be raised and which can be intercepted by: ON <i>condition</i> action; Programmers can also define and use their own named conditions. </p><p>Like the <i>unstructured if</i>, only one statement can be specified so in many cases a GOTO is needed to decide where flow of control should resume. </p><p>Unfortunately, some implementations had a substantial overhead in both space and time (especially SUBSCRIPTRANGE), so many programmers tried to avoid using conditions. </p><p>Common Syntax examples: </p> <pre> <b>ON</b> <i>condition</i> <b>GOTO</b> <i>label</i> </pre> <div class="mw-heading mw-heading3"><h3 id="Exceptions">Exceptions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=27" title="Edit section: Exceptions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Exception_handling" title="Exception handling">Exception handling</a></div> <p>Modern languages have a specialized structured construct for exception handling which does not rely on the use of <code>GOTO</code> or (multi-level) breaks or returns. For example, in C++ one can write: </p> <div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">try</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">xxx1</span><span class="w"> </span><span class="c1">// Somewhere in here</span> <span class="w"> </span><span class="n">xxx2</span><span class="w"> </span><span class="c1">// use: &#39;&#39;&#39;throw&#39;&#39;&#39; someValue;</span> <span class="w"> </span><span class="n">xxx3</span> <span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">someClass</span><span class="o">&amp;</span><span class="w"> </span><span class="n">someId</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// catch value of someClass</span> <span class="w"> </span><span class="n">actionForSomeClass</span><span class="w"> </span> <span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">someType</span><span class="o">&amp;</span><span class="w"> </span><span class="n">anotherId</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// catch value of someType</span> <span class="w"> </span><span class="n">actionForSomeType</span> <span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(...)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// catch anything not already caught</span> <span class="w"> </span><span class="n">actionForAnythingElse</span> <span class="p">}</span> </pre></div> <p>Any number and variety of <code>catch</code> clauses can be used above. If there is no <code>catch</code> matching a particular <code>throw</code>, control percolates back through subroutine calls and/or nested blocks until a matching <code>catch</code> is found or until the end of the main program is reached, at which point the program is forcibly stopped with a suitable error message. </p><p>Via C++'s influence, <code>catch</code> is the keyword reserved for declaring a pattern-matching exception handler in other languages popular today, like Java or C#. Some other languages like Ada use the keyword <code>exception</code> to introduce an exception handler and then may even employ a different keyword (<code>when</code> in Ada) for the pattern matching. A few languages like <a href="/wiki/AppleScript" title="AppleScript">AppleScript</a> incorporate placeholders in the exception handler syntax to automatically extract several pieces of information when the exception occurs. This approach is exemplified below by the <code>on error</code> construct from AppleScript: </p> <div class="mw-highlight mw-highlight-lang-applescript mw-content-ltr" dir="ltr"><pre><span></span><span class="k">try</span> <span class="k">set</span> <span class="nv">myNumber</span> <span class="k">to</span> <span class="nv">myNumber</span> <span class="o">/</span> <span class="mi">0</span> <span class="k">on</span> <span class="k">error</span> <span class="nv">e</span> <span class="nv">number</span> <span class="nv">n</span> <span class="k">from</span> <span class="nv">f</span> <span class="k">to</span> <span class="nv">t</span> <span class="nv">partial</span> <span class="no">result</span> <span class="nv">pr</span> <span class="k">if</span> <span class="p">(</span> <span class="nv">e</span> <span class="o">=</span> <span class="s2">&quot;Can&#39;t divide by zero&quot;</span> <span class="p">)</span> <span class="k">then</span> <span class="nb">display dialog</span> <span class="s2">&quot;You must not do that&quot;</span> <span class="k">end</span> <span class="k">try</span> </pre></div> <p>David Watt's 2004 textbook also analyzes exception handling in the framework of sequencers (introduced in this article in the section on early exits from loops). Watt notes that an abnormal situation, generally exemplified with arithmetic overflows or <a href="/wiki/Input/output" title="Input/output">input/output</a> failures like file not found, is a kind of error that "is detected in some low-level program unit, but [for which] a handler is more naturally located in a high-level program unit". For example, a program might contain several calls to read files, but the action to perform when a file is not found depends on the meaning (purpose) of the file in question to the program and thus a handling routine for this abnormal situation cannot be located in low-level system code. Watts further notes that introducing status flags testing in the caller, as single-exit structured programming or even (multi-exit) return sequencers would entail, results in a situation where "the application code tends to get cluttered by tests of status flags" and that "the programmer might forgetfully or lazily omit to test a status flag. In fact, abnormal situations represented by status flags are by default ignored!" Watt notes that in contrast to status flags testing, exceptions have the opposite <a href="/wiki/Default_(computer_science)" title="Default (computer science)">default behavior</a>, causing the program to terminate unless the program deals with the exception explicitly in some way, possibly by adding explicit code to ignore it. Based on these arguments, Watt concludes that jump sequencers or escape sequencers are less suitable as a dedicated exception sequencer with the semantics discussed above.<sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">&#91;</span>24<span class="cite-bracket">&#93;</span></a></sup> </p><p>In Object Pascal, D, Java, C#, and Python a <code>finally</code> clause can be added to the <code>try</code> construct. No matter how control leaves the <code>try</code> the code inside the <code>finally</code> clause is guaranteed to execute. This is useful when writing code that must relinquish an expensive resource (such as an opened file or a database connection) when finished processing: </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="n">FileStream</span><span class="w"> </span><span class="n">stm</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">null</span><span class="p">;</span><span class="w"> </span><span class="c1">// C# example</span> <span class="k">try</span> <span class="p">{</span> <span class="w"> </span><span class="n">stm</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">FileStream</span><span class="p">(</span><span class="s">&quot;logfile.txt&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">FileMode</span><span class="p">.</span><span class="n">Create</span><span class="p">);</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nf">ProcessStuff</span><span class="p">(</span><span class="n">stm</span><span class="p">);</span><span class="w"> </span><span class="c1">// may throw an exception</span> <span class="p">}</span><span class="w"> </span> <span class="k">finally</span> <span class="p">{</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">stm</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="k">null</span><span class="p">)</span> <span class="w"> </span><span class="n">stm</span><span class="p">.</span><span class="n">Close</span><span class="p">();</span> <span class="p">}</span> </pre></div> <p>Since this pattern is fairly common, C# has a special syntax: </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">using</span><span class="w"> </span><span class="p">(</span><span class="kt">var</span><span class="w"> </span><span class="n">stm</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">FileStream</span><span class="p">(</span><span class="s">&quot;logfile.txt&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">FileMode</span><span class="p">.</span><span class="n">Create</span><span class="p">))</span> <span class="p">{</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nf">ProcessStuff</span><span class="p">(</span><span class="n">stm</span><span class="p">);</span><span class="w"> </span><span class="c1">// may throw an exception</span> <span class="p">}</span> </pre></div> <p>Upon leaving the <code>using</code>-block, the compiler guarantees that the <code>stm</code> object is released, effectively <a href="/wiki/Name_binding" title="Name binding">binding</a> the variable to the file stream while abstracting from the side effects of initializing and releasing the file. Python's <code>with</code> statement and Ruby's block argument to <code>File.open</code> are used to similar effect. </p><p>All the languages mentioned above define standard exceptions and the circumstances under which they are thrown. Users can throw exceptions of their own; C++ allows users to throw and catch almost any type, including basic types like <code>int</code>, whereas other languages like Java are less permissive. </p> <div class="mw-heading mw-heading3"><h3 id="Continuations">Continuations</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=28" title="Edit section: Continuations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Continuation" title="Continuation">Continuation</a></div> <div class="mw-heading mw-heading3"><h3 id="Async">Async</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=29" title="Edit section: Async"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>C# 5.0 introduced the async keyword for supporting <a href="/wiki/Asynchronous_I/O" title="Asynchronous I/O">asynchronous I/O</a> in a "direct style". </p> <div class="mw-heading mw-heading3"><h3 id="Generators">Generators</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=30" title="Edit section: Generators"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Generator_(computer_science)" class="mw-redirect" title="Generator (computer science)">Generator (computer science)</a></div> <p><a href="/wiki/Generator_(computer_science)" class="mw-redirect" title="Generator (computer science)">Generators</a>, also known as semicoroutines, allow control to be yielded to a consumer method temporarily, typically using a <code class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><span class="k">yield</span></code> keyword (<a rel="nofollow" class="external text" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield">yield description</a>) . Like the async keyword, this supports programming in a "direct style". </p> <div class="mw-heading mw-heading3"><h3 id="Coroutines">Coroutines</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=31" title="Edit section: Coroutines"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Coroutine" title="Coroutine">Coroutine</a></div> <p><a href="/wiki/Coroutines" class="mw-redirect" title="Coroutines">Coroutines</a> are functions that can yield control to each other - a form of <a href="/wiki/Co-operative_multitasking" class="mw-redirect" title="Co-operative multitasking">co-operative multitasking</a> without threads. </p><p>Coroutines can be implemented as a library if the programming language provides either continuations or generators - so the distinction between coroutines and generators in practice is a technical detail. </p> <div class="mw-heading mw-heading3"><h3 id="Non-local_control_flow_cross_reference">Non-local control flow cross reference</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=32" title="Edit section: Non-local control flow cross reference"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <table class="wikitable"> <tbody><tr> <th><a href="/wiki/Programming_language" title="Programming language">Programming language</a> </th> <th>conditions </th> <th>exceptions </th> <th>generators/coroutines </th> <th>async </th></tr> <tr> <td><a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td></tr> <tr> <td><a href="/wiki/C%2B%2B" title="C++">C++</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td></tr> <tr> <td><a href="/wiki/COBOL" title="COBOL">COBOL</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td></tr> <tr> <td><a href="/wiki/Common_Lisp" title="Common Lisp">Common Lisp</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/D_(programming_language)" title="D (programming language)">D</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/Eiffel_(programming_language)" title="Eiffel (programming language)">Eiffel</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/Erlang_(programming_language)" title="Erlang (programming language)">Erlang</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/F_Sharp_(programming_language)" title="F Sharp (programming language)">F#</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td></tr> <tr> <td><a href="/wiki/Go_(programming_language)" title="Go (programming language)">Go</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/Haskell" title="Haskell">Haskell</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td></tr> <tr> <td><a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td></tr> <tr> <td><a href="/wiki/JavaScript" title="JavaScript">JavaScript</a> </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td></tr> <tr> <td><a href="/wiki/Objective-C" title="Objective-C">Objective-C</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/PHP" title="PHP">PHP</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/PL/I" title="PL/I">PL/I</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td></tr> <tr> <td><a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">&#91;</span>25<span class="cite-bracket">&#93;</span></a></sup> </td></tr> <tr> <td><a href="/wiki/Rebol" title="Rebol">Rebol</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">via extension<sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">&#91;</span>26<span class="cite-bracket">&#93;</span></a></sup> </td></tr> <tr> <td><a href="/wiki/Rust_(programming_language)" title="Rust (programming language)">Rust</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">experimental <sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">&#91;</span>27<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">&#91;</span>28<span class="cite-bracket">&#93;</span></a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">&#91;</span>29<span class="cite-bracket">&#93;</span></a></sup> </td></tr> <tr> <td><a href="/wiki/Scala_(programming_language)" title="Scala (programming language)">Scala</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">via experimental extension<sup id="cite_ref-31" class="reference"><a href="#cite_note-31"><span class="cite-bracket">&#91;</span>30<span class="cite-bracket">&#93;</span></a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">via experimental extension </td></tr> <tr> <td><a href="/wiki/Tcl" title="Tcl">Tcl</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">via traces </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">via event loop </td></tr> <tr> <td><a href="/wiki/Visual_Basic_.NET" class="mw-redirect" title="Visual Basic .NET">Visual Basic .NET</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr> <tr> <td><a href="/wiki/PowerShell" title="PowerShell">PowerShell</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No </td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Un­known">? </td></tr></tbody></table> <div class="mw-heading mw-heading2"><h2 id="Proposed_control_structures">Proposed control structures</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=33" title="Edit section: Proposed control structures"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In a spoof <a href="/wiki/Datamation" title="Datamation">Datamation</a> article<sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">&#91;</span>31<span class="cite-bracket">&#93;</span></a></sup> in 1973, R. Lawrence Clark suggested that the GOTO statement could be replaced by the <a href="/wiki/COMEFROM" title="COMEFROM">COMEFROM</a> statement, and provides some entertaining examples. COMEFROM was implemented in one <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> named <a href="/wiki/INTERCAL" title="INTERCAL">INTERCAL</a>. </p><p><a href="/wiki/Donald_Knuth" title="Donald Knuth">Donald Knuth</a>'s 1974 article "Structured Programming with go to Statements",<sup id="cite_ref-33" class="reference"><a href="#cite_note-33"><span class="cite-bracket">&#91;</span>32<span class="cite-bracket">&#93;</span></a></sup> identifies two situations which were not covered by the control structures listed above, and gave examples of control structures which could handle these situations. Despite their utility, these constructs have not yet found their way into mainstream programming languages. </p> <div class="mw-heading mw-heading3"><h3 id="Loop_with_test_in_the_middle">Loop with test in the middle</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=34" title="Edit section: Loop with test in the middle"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The following was proposed by <a href="/wiki/Ole-Johan_Dahl" title="Ole-Johan Dahl">Dahl</a> in 1972:<sup id="cite_ref-34" class="reference"><a href="#cite_note-34"><span class="cite-bracket">&#91;</span>33<span class="cite-bracket">&#93;</span></a></sup> </p> <pre> <b>loop</b> <b>loop</b> xxx1 read(char); <b>while</b> test; <b>while</b> <b>not</b> atEndOfFile; xxx2 write(char); <b>repeat</b>; <b>repeat</b>; </pre> <p>If <i>xxx1</i> is omitted, we get a loop with the test at the top (a traditional <b>while</b> loop). If <i>xxx2</i> is omitted, we get a loop with the test at the bottom, equivalent to a <b>do while</b> loop in many languages. If <b>while</b> is omitted, we get an infinite loop. The construction here can be thought of as a <b>do</b> loop with the while check in the middle. Hence this single construction can replace several constructions in most programming languages. </p><p>Languages lacking this construct generally emulate it using an equivalent infinite-loop-with-break idiom: </p> <pre><b>while</b> (true) { xxx1 <b>if</b> (<b>not</b> test) <b>break</b> xxx2 } </pre> <p>A possible variant is to allow more than one <b>while</b> test; within the loop, but the use of <b>exitwhen</b> (see next section) appears to cover this case better. </p><p>In <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>, the above loop construct (<b>loop</b>-<b>while</b>-<b>repeat</b>) can be represented using a standard infinite loop (<b>loop</b> - <b>end loop</b>) that has an <b>exit when</b> clause in the middle (not to be confused with the <b>exitwhen</b> statement in the following section). </p> <div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">with</span> <span class="n">Ada.Text_IO</span><span class="p">;</span> <span class="kn">with</span> <span class="n">Ada.Integer_Text_IO</span><span class="p">;</span> <span class="kd">procedure</span> <span class="nf">Print_Squares</span> <span class="kr">is</span> <span class="n">X</span> <span class="p">:</span> <span class="kt">Integer</span><span class="p">;</span> <span class="kr">begin</span> <span class="nl">Read_Data</span> <span class="p">:</span> <span class="kr">loop</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Integer_Text_IO</span><span class="p">.</span><span class="n">Get</span><span class="p">(</span><span class="n">X</span><span class="p">);</span> <span class="kr">exit</span> <span class="n">Read_Data</span> <span class="kr">when</span> <span class="n">X</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Text</span> <span class="n">IO</span><span class="p">.</span><span class="n">Put</span> <span class="p">(</span><span class="n">X</span> <span class="o">*</span> <span class="n">X</span><span class="p">);</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Text</span> <span class="n">IO</span><span class="p">.</span><span class="n">New_Line</span><span class="p">;</span> <span class="kr">end</span> <span class="kr">loop</span> <span class="nf">Read_Data</span><span class="p">;</span> <span class="kr">end</span> <span class="nf">Print_Squares</span><span class="p">;</span> </pre></div> <p>Naming a loop (like <i>Read_Data</i> in this example) is optional but permits leaving the outer loop of several nested loops. </p> <div class="mw-heading mw-heading3"><h3 id="Multiple_early_exit/exit_from_nested_loops"><span id="Multiple_early_exit.2Fexit_from_nested_loops"></span>Multiple early exit/exit from nested loops</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=35" title="Edit section: Multiple early exit/exit from nested loops"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Zahn%27s_construct" title="Zahn&#39;s construct">This construct</a> was proposed by <a href="/wiki/Zahn%27s_construct" title="Zahn&#39;s construct">Zahn</a> in 1974.<sup id="cite_ref-35" class="reference"><a href="#cite_note-35"><span class="cite-bracket">&#91;</span>34<span class="cite-bracket">&#93;</span></a></sup> A modified version is presented here. </p> <pre> <b>exitwhen</b> EventA <b>or</b> EventB <b>or</b> EventC; xxx <b>exits</b> EventA: actionA EventB: actionB EventC: actionC <b>endexit</b>; </pre> <p><b>exitwhen</b> is used to specify the events which may occur within <i>xxx</i>, their occurrence is indicated by using the name of the event as a statement. When some event does occur, the relevant action is carried out, and then control passes just after <b>endexit</b>. This construction provides a very clear separation between determining that some situation applies, and the action to be taken for that situation. </p><p><b>exitwhen</b> is conceptually similar to <a href="/wiki/Exception_handling" title="Exception handling">exception handling</a>, and exceptions or similar constructs are used for this purpose in many languages. </p><p>The following simple example involves searching a two-dimensional table for a particular item. </p> <pre> <b>exitwhen</b> found <b>or</b> missing; <b>for</b> I&#160;:= 1 <b>to</b> N <b>do</b> <b>for</b> J&#160;:= 1 <b>to</b> M <b>do</b> <b>if</b> table[I,J] = target <b>then</b> found; missing; <b>exits</b> found: print ("item is in table"); missing: print ("item is not in table"); <b>endexit</b>; </pre> <div class="mw-heading mw-heading2"><h2 id="Security">Security</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=36" title="Edit section: Security"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>One way to attack a piece of software is to redirect the flow of execution of a program. A variety of <a href="/wiki/Control-flow_integrity" title="Control-flow integrity">control-flow integrity</a> techniques, including <a href="/wiki/Stack_canary" class="mw-redirect" title="Stack canary">stack canaries</a>, <a href="/wiki/Buffer_overflow_protection" title="Buffer overflow protection">buffer overflow protection</a>, shadow stacks, and <a href="/wiki/Virtual_method_table" title="Virtual method table">vtable</a> pointer verification, are used to defend against these attacks.<sup id="cite_ref-36" class="reference"><a href="#cite_note-36"><span class="cite-bracket">&#91;</span>35<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-37" class="reference"><a href="#cite_note-37"><span class="cite-bracket">&#91;</span>36<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-38" class="reference"><a href="#cite_note-38"><span class="cite-bracket">&#91;</span>37<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=37" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1184024115">.mw-parser-output .div-col{margin-top:0.3em;column-width:30em}.mw-parser-output .div-col-small{font-size:90%}.mw-parser-output .div-col-rules{column-rule:1px solid #aaa}.mw-parser-output .div-col dl,.mw-parser-output .div-col ol,.mw-parser-output .div-col ul{margin-top:0}.mw-parser-output .div-col li,.mw-parser-output .div-col dd{page-break-inside:avoid;break-inside:avoid-column}</style><div class="div-col"> <ul><li><a href="/wiki/Branch_(computer_science)" title="Branch (computer science)">Branch (computer science)</a></li> <li><a href="/wiki/Control_flow_analysis" class="mw-redirect" title="Control flow analysis">Control-flow analysis</a></li> <li><a href="/wiki/Control-flow_diagram" title="Control-flow diagram">Control-flow diagram</a></li> <li><a href="/wiki/Control-flow_graph" title="Control-flow graph">Control-flow graph</a></li> <li><a href="/wiki/Control_table" title="Control table">Control table</a></li> <li><a href="/wiki/Coroutine" title="Coroutine">Coroutine</a></li> <li><a href="/wiki/Cyclomatic_complexity" title="Cyclomatic complexity">Cyclomatic complexity</a></li> <li><a href="/wiki/DRAKON" title="DRAKON">Drakon-chart</a></li> <li><a href="/wiki/Flowchart" title="Flowchart">Flowchart</a></li> <li><a href="/wiki/Goto" title="Goto">Goto</a></li> <li><a href="/wiki/Jeroo" title="Jeroo">Jeroo</a>, helps learn control structures</li> <li><a href="/wiki/Main_loop" class="mw-redirect" title="Main loop">Main loop</a></li> <li><a href="/wiki/Recursion" title="Recursion">Recursion</a></li> <li><a href="/wiki/Scheduling_(computing)" title="Scheduling (computing)">Scheduling (computing)</a></li> <li><a href="/wiki/Spaghetti_code" title="Spaghetti code">Spaghetti code</a></li> <li><a href="/wiki/Structured_programming" title="Structured programming">Structured programming</a></li> <li><a href="/wiki/Subroutine" class="mw-redirect" title="Subroutine">Subroutine</a></li> <li><a href="/wiki/Switch_statement" title="Switch statement">Switch statement</a>, alters control flow conditionally</li> <li><a href="/wiki/Zahn%27s_construct" title="Zahn&#39;s construct">Zahn's construct</a></li></ul> </div> <div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=38" title="Edit section: Notes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist reflist-lower-alpha"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text">In Fortran, this statement was deemed obsolescent in Fortran-90, and deleted as of Fortran 2018.</span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="References">References</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=39" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1239543626" /><div class="reflist"> <div class="mw-references-wrap mw-references-columns"><ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">Böhm, Jacopini. "Flow diagrams, turing machines and languages with only two formation rules" <a href="/wiki/Comm._ACM" class="mw-redirect" title="Comm. ACM">Comm. ACM</a>, 9(5):366-371, May 1966.</span> </li> <li id="cite_note-roberts-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-roberts_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-roberts_2-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">Roberts, E. [1995] "<a rel="nofollow" class="external text" href="http://cs.stanford.edu/people/eroberts/papers/SIGCSE-1995/LoopExits.pdf">Loop Exits and Structured Programming: Reopening the Debate</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140725130816/http://cs.stanford.edu/people/eroberts/papers/SIGCSE-1995/LoopExits.pdf">Archived</a> 2014-07-25 at the <a href="/wiki/Wayback_Machine" title="Wayback Machine">Wayback Machine</a>," ACM SIGCSE Bulletin, (27)1: 268–272.</span> </li> <li id="cite_note-WattFindlay2004-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-WattFindlay2004_3-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite id="CITEREFDavid_Anthony_WattWilliam_Findlay2004" class="citation book cs1">David Anthony Watt; William Findlay (2004). <i>Programming language design concepts</i>. John Wiley &amp; Sons. p.&#160;228. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-470-85320-7" title="Special:BookSources/978-0-470-85320-7"><bdi>978-0-470-85320-7</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Programming+language+design+concepts&amp;rft.pages=228&amp;rft.pub=John+Wiley+%26+Sons&amp;rft.date=2004&amp;rft.isbn=978-0-470-85320-7&amp;rft.au=David+Anthony+Watt&amp;rft.au=William+Findlay&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.geeksforgeeks.org/nested-loops-in-c-with-examples/">"Nested Loops in C with Examples"</a>. <i>GeeksforGeeks</i>. 2019-11-25<span class="reference-accessdate">. Retrieved <span class="nowrap">2024-03-14</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=GeeksforGeeks&amp;rft.atitle=Nested+Loops+in+C+with+Examples&amp;rft.date=2019-11-25&amp;rft_id=https%3A%2F%2Fwww.geeksforgeeks.org%2Fnested-loops-in-c-with-examples%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.w3schools.com/python/gloss_python_for_nested.asp">"Python Nested Loops"</a>. <i>www.w3schools.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2024-03-14</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=www.w3schools.com&amp;rft.atitle=Python+Nested+Loops&amp;rft_id=https%3A%2F%2Fwww.w3schools.com%2Fpython%2Fgloss_python_for_nested.asp&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFDean2019" class="citation web cs1">Dean, Jenna (2019-11-22). <a rel="nofollow" class="external text" href="https://medium.com/swlh/nested-loops-ee1dbb9fc8ab">"Nested Loops"</a>. <i>The Startup</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2024-03-14</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=The+Startup&amp;rft.atitle=Nested+Loops&amp;rft.date=2019-11-22&amp;rft.aulast=Dean&amp;rft.aufirst=Jenna&amp;rft_id=https%3A%2F%2Fmedium.com%2Fswlh%2Fnested-loops-ee1dbb9fc8ab&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><a href="https://en.wikibooks.org/wiki/Ada_Programming/Control#Endless_Loop" class="extiw" title="b:Ada Programming/Control">Ada Programming: Control: Endless Loop</a></span> </li> <li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20200728081722/http://www.megacpptutorials.com/2012/12/what-is-loop.html">"What is a loop and how we can use them?"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.megacpptutorials.com/2012/12/what-is-loop.html">the original</a> on 2020-07-28<span class="reference-accessdate">. Retrieved <span class="nowrap">2020-05-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=What+is+a+loop+and+how+we+can+use+them%3F&amp;rft_id=http%3A%2F%2Fwww.megacpptutorials.com%2F2012%2F12%2Fwhat-is-loop.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://perldoc.perl.org/functions/redo.html">"redo - perldoc.perl.org"</a>. <i>perldoc.perl.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-09-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=perldoc.perl.org&amp;rft.atitle=redo+-+perldoc.perl.org&amp;rft_id=https%3A%2F%2Fperldoc.perl.org%2Ffunctions%2Fredo.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.ruby-lang.org/en/2.4.0/syntax/control_expressions_rdoc.html">"control_expressions - Documentation for Ruby 2.4.0"</a>. <i>docs.ruby-lang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-09-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=docs.ruby-lang.org&amp;rft.atitle=control_expressions+-+Documentation+for+Ruby+2.4.0&amp;rft_id=https%3A%2F%2Fdocs.ruby-lang.org%2Fen%2F2.4.0%2Fsyntax%2Fcontrol_expressions_rdoc.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.ruby-lang.org/en/2.3.0/syntax/control_expressions_rdoc.html">"control_expressions - Documentation for Ruby 2.3.0"</a>. <i>docs.ruby-lang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-09-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=docs.ruby-lang.org&amp;rft.atitle=control_expressions+-+Documentation+for+Ruby+2.3.0&amp;rft_id=https%3A%2F%2Fdocs.ruby-lang.org%2Fen%2F2.3.0%2Fsyntax%2Fcontrol_expressions_rdoc.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text">Advanced Bash Scripting Guide: <a rel="nofollow" class="external text" href="http://tldp.org/LDP/abs/html/loopcontrol.html">11.3. Loop Control</a></span> </li> <li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text">PHP Manual: "<a rel="nofollow" class="external text" href="http://php.net/manual/en/control-structures.break.php">break</a>"</span> </li> <li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text">perldoc: <a rel="nofollow" class="external text" href="http://perldoc.perl.org/functions/last.html">last</a></span> </li> <li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text">comp.lang.c FAQ list · "<a rel="nofollow" class="external text" href="http://c-faq.com/misc/multibreak.html">Question 20.20b</a>"</span> </li> <li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://mail.python.org/pipermail/python-3000/2007-July/008663.html">[Python-3000] Announcing PEP 3136</a>, Guido van Rossum</span> </li> <li id="cite_note-kozen-18"><span class="mw-cite-backlink">^ <a href="#cite_ref-kozen_18-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-kozen_18-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFKozen2008" class="citation book cs1">Kozen, Dexter (2008). "The Böhm–Jacopini Theorem is False, Propositionally". <a rel="nofollow" class="external text" href="http://www.cs.cornell.edu/~kozen/papers/BohmJacopini.pdf"><i>Mathematics of Program Construction</i></a> <span class="cs1-format">(PDF)</span>. Lecture Notes in Computer Science. Vol.&#160;5133. pp.&#160;<span class="nowrap">177–</span>192. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.218.9241">10.1.1.218.9241</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-540-70594-9_11">10.1007/978-3-540-70594-9_11</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-3-540-70593-2" title="Special:BookSources/978-3-540-70593-2"><bdi>978-3-540-70593-2</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=The+B%C3%B6hm%E2%80%93Jacopini+Theorem+is+False%2C+Propositionally&amp;rft.btitle=Mathematics+of+Program+Construction&amp;rft.series=Lecture+Notes+in+Computer+Science&amp;rft.pages=%3Cspan+class%3D%22nowrap%22%3E177-%3C%2Fspan%3E192&amp;rft.date=2008&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.218.9241%23id-name%3DCiteSeerX&amp;rft_id=info%3Adoi%2F10.1007%2F978-3-540-70594-9_11&amp;rft.isbn=978-3-540-70593-2&amp;rft.aulast=Kozen&amp;rft.aufirst=Dexter&amp;rft_id=http%3A%2F%2Fwww.cs.cornell.edu%2F~kozen%2Fpapers%2FBohmJacopini.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text">Kosaraju, S. Rao. "Analysis of structured programs," Proc. Fifth Annual ACM Syrup. Theory of Computing, (May 1973), 240-252; also in J. Computer and System Sciences, 9, 3 (December 1974). cited by <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFKnuth1974" class="citation journal cs1"><a href="/wiki/Donald_Knuth" title="Donald Knuth">Knuth, Donald</a> (1974). "Structured Programming with go to Statements". <i>Computing Surveys</i>. <b>6</b> (4): <span class="nowrap">261–</span>301. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.103.6084">10.1.1.103.6084</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F356635.356640">10.1145/356635.356640</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:207630080">207630080</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Computing+Surveys&amp;rft.atitle=Structured+Programming+with+go+to+Statements&amp;rft.volume=6&amp;rft.issue=4&amp;rft.pages=%3Cspan+class%3D%22nowrap%22%3E261-%3C%2Fspan%3E301&amp;rft.date=1974&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.103.6084%23id-name%3DCiteSeerX&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A207630080%23id-name%3DS2CID&amp;rft_id=info%3Adoi%2F10.1145%2F356635.356640&amp;rft.aulast=Knuth&amp;rft.aufirst=Donald&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-WattFindlay2004b-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-WattFindlay2004b_20-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFDavid_Anthony_WattWilliam_Findlay2004" class="citation book cs1">David Anthony Watt; William Findlay (2004). <i>Programming language design concepts</i>. John Wiley &amp; Sons. pp.&#160;<span class="nowrap">215–</span>221. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-470-85320-7" title="Special:BookSources/978-0-470-85320-7"><bdi>978-0-470-85320-7</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Programming+language+design+concepts&amp;rft.pages=%3Cspan+class%3D%22nowrap%22%3E215-%3C%2Fspan%3E221&amp;rft.pub=John+Wiley+%26+Sons&amp;rft.date=2004&amp;rft.isbn=978-0-470-85320-7&amp;rft.au=David+Anthony+Watt&amp;rft.au=William+Findlay&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFMeyer1991" class="citation book cs1">Meyer, Bertrand (1991). <i>Eiffel: The Language</i>. Prentice Hall. pp.&#160;<span class="nowrap">129–</span>131.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Eiffel%3A+The+Language&amp;rft.pages=%3Cspan+class%3D%22nowrap%22%3E129-%3C%2Fspan%3E131&amp;rft.pub=Prentice+Hall&amp;rft.date=1991&amp;rft.aulast=Meyer&amp;rft.aufirst=Bertrand&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.lispworks.com/documentation/HyperSpec/Body/m_loop.htm">"Common Lisp LOOP macro"</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Common+Lisp+LOOP+macro&amp;rft_id=http%3A%2F%2Fwww.lispworks.com%2Fdocumentation%2FHyperSpec%2FBody%2Fm_loop.htm&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www.sgi.com/tech/stl/for_each.html">for_each</a>. Sgi.com. Retrieved on 2010-11-09.</span> </li> <li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://boost-sandbox.sourceforge.net/libs/foreach/doc/html/">Chapter 1. Boost.Foreach</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20100129070613/http://boost-sandbox.sourceforge.net/libs/foreach/doc/html/">Archived</a> 2010-01-29 at the <a href="/wiki/Wayback_Machine" title="Wayback Machine">Wayback Machine</a>. Boost-sandbox.sourceforge.net (2009-12-19). Retrieved on 2010-11-09.</span> </li> <li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFDavid_Anthony_WattWilliam_Findlay2004" class="citation book cs1">David Anthony Watt; William Findlay (2004). <i>Programming language design concepts</i>. John Wiley &amp; Sons. pp.&#160;<span class="nowrap">221–</span>222. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-470-85320-7" title="Special:BookSources/978-0-470-85320-7"><bdi>978-0-470-85320-7</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Programming+language+design+concepts&amp;rft.pages=%3Cspan+class%3D%22nowrap%22%3E221-%3C%2Fspan%3E222&amp;rft.pub=John+Wiley+%26+Sons&amp;rft.date=2004&amp;rft.isbn=978-0-470-85320-7&amp;rft.au=David+Anthony+Watt&amp;rft.au=William+Findlay&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.python.org/3/library/asyncio.html">"Asyncio: Asynchronous I/O: Python 3.10.2 documentation"</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Asyncio%3A+Asynchronous+I%2FO%3A+Python+3.10.2+documentation&amp;rft_id=https%3A%2F%2Fdocs.python.org%2F3%2Flibrary%2Fasyncio.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/socketry/async">"Socketry/Async"</a>. <i><a href="/wiki/GitHub" title="GitHub">GitHub</a></i>. 25 February 2022.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=GitHub&amp;rft.atitle=Socketry%2FAsync&amp;rft.date=2022-02-25&amp;rft_id=https%3A%2F%2Fgithub.com%2Fsocketry%2Fasync&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://doc.rust-lang.org/beta/unstable-book/language-features/generators.html">"Generators - the Rust Unstable Book"</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Generators+-+the+Rust+Unstable+Book&amp;rft_id=https%3A%2F%2Fdoc.rust-lang.org%2Fbeta%2Funstable-book%2Flanguage-features%2Fgenerators.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.rs/corona/0.4.3/corona/">"Corona - Rust"</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Corona+-+Rust&amp;rft_id=https%3A%2F%2Fdocs.rs%2Fcorona%2F0.4.3%2Fcorona%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-30">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://rust-lang.github.io/async-book/">"Getting Started - Asynchronous Programming in Rust"</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Getting+Started+-+Asynchronous+Programming+in+Rust&amp;rft_id=https%3A%2F%2Frust-lang.github.io%2Fasync-book%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-31">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://storm-enroute.com/coroutines/">"Jitsi Meet"</a>. Storm-enroute.com<span class="reference-accessdate">. Retrieved <span class="nowrap">2022-09-07</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Jitsi+Meet&amp;rft.pub=Storm-enroute.com&amp;rft_id=http%3A%2F%2Fstorm-enroute.com%2Fcoroutines%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-32">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www.fortran.com/fortran/come_from.html">We don't know where to GOTO if we don't know where we've COME FROM. This (spoof) linguistic innovation lives up to all expectations.</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20180716171336/http://www.fortran.com/fortran/come_from.html">Archived</a> 2018-07-16 at the <a href="/wiki/Wayback_Machine" title="Wayback Machine">Wayback Machine</a> By R. Lawrence Clark* From Datamation, December, 1973</span> </li> <li id="cite_note-33"><span class="mw-cite-backlink"><b><a href="#cite_ref-33">^</a></b></span> <span class="reference-text">Knuth, Donald E. "Structured Programming with go to Statements" <a href="/wiki/ACM_Computing_Surveys" title="ACM Computing Surveys">ACM Computing Surveys</a> 6(4):261-301, December 1974.</span> </li> <li id="cite_note-34"><span class="mw-cite-backlink"><b><a href="#cite_ref-34">^</a></b></span> <span class="reference-text">Dahl &amp; Dijkstra &amp; Hoare, "Structured Programming" Academic Press, 1972.</span> </li> <li id="cite_note-35"><span class="mw-cite-backlink"><b><a href="#cite_ref-35">^</a></b></span> <span class="reference-text">Zahn, C. T. "A control statement for natural top-down structured programming" presented at Symposium on Programming Languages, Paris, 1974.</span> </li> <li id="cite_note-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-36">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFPayerKuznetsov" class="citation web cs1"><a href="/wiki/Mathias_Payer" title="Mathias Payer">Payer, Mathias</a>; Kuznetsov, Volodymyr. <a rel="nofollow" class="external text" href="https://nebelwelt.net/blog/20141007-CFICPSCPIdiffs.html">"On differences between the CFI, CPS, and CPI properties"</a>. <i>nebelwelt.net</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2016-06-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=nebelwelt.net&amp;rft.atitle=On+differences+between+the+CFI%2C+CPS%2C+and+CPI+properties&amp;rft.aulast=Payer&amp;rft.aufirst=Mathias&amp;rft.au=Kuznetsov%2C+Volodymyr&amp;rft_id=https%3A%2F%2Fnebelwelt.net%2Fblog%2F20141007-CFICPSCPIdiffs.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-37"><span class="mw-cite-backlink"><b><a href="#cite_ref-37">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.darkreading.com/vulnerabilities---threats/adobe-flash-bug-discovery-leads-to-new-attack-mitigation-method/d/d-id/1323092">"Adobe Flash Bug Discovery Leads To New Attack Mitigation Method"</a>. <i>Dark Reading</i>. 10 November 2015<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-06-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Dark+Reading&amp;rft.atitle=Adobe+Flash+Bug+Discovery+Leads+To+New+Attack+Mitigation+Method&amp;rft.date=2015-11-10&amp;rft_id=http%3A%2F%2Fwww.darkreading.com%2Fvulnerabilities---threats%2Fadobe-flash-bug-discovery-leads-to-new-attack-mitigation-method%2Fd%2Fd-id%2F1323092&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> <li id="cite_note-38"><span class="mw-cite-backlink"><b><a href="#cite_ref-38">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFEndgame" class="citation pressrelease cs1">Endgame. <a rel="nofollow" class="external text" href="http://www.prnewswire.com/news-releases/endgame-to-present-at-black-hat-usa-2016-300267060.html">"Endgame to Present at Black Hat USA 2016"</a>. <i>www.prnewswire.com</i> (Press release)<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-06-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Endgame+to+Present+at+Black+Hat+USA+2016&amp;rft.au=Endgame&amp;rft_id=http%3A%2F%2Fwww.prnewswire.com%2Fnews-releases%2Fendgame-to-present-at-black-hat-usa-2016-300267060.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span></span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=40" title="Edit section: Further reading"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>Hoare, C. A. R. "Partition: Algorithm 63," "Quicksort: Algorithm 64," and "Find: Algorithm 65." Comm. ACM 4, 321–322, 1961.</li></ul> <div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Control_flow&amp;action=edit&amp;section=41" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1235681985">.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}</style><style data-mw-deduplicate="TemplateStyles:r1237033735">@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}</style><div class="side-box side-box-right plainlinks sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}</style> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><a href="/wiki/File:Wikibooks-logo-en-noslogan.svg" class="mw-file-description"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/60px-Wikibooks-logo-en-noslogan.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/120px-Wikibooks-logo-en-noslogan.svg.png 2x" data-file-width="400" data-file-height="400" /></a></span></div> <div class="side-box-text plainlist">The Wikibook <i><a href="https://en.wikibooks.org/wiki/Ada_Programming" class="extiw" title="wikibooks:Ada Programming">Ada Programming</a></i> has a page on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Ada_Programming/Control" class="extiw" title="wikibooks:Ada Programming/Control">Control</a></b></i></div></div> </div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1235681985" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1237033735" /><div class="side-box side-box-right plainlinks sistersitebox"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1126788409" /> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><a href="/wiki/File:Wikibooks-logo-en-noslogan.svg" class="mw-file-description"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/60px-Wikibooks-logo-en-noslogan.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/120px-Wikibooks-logo-en-noslogan.svg.png 2x" data-file-width="400" data-file-height="400" /></a></span></div> <div class="side-box-text plainlist">The Wikibook <i><a href="https://en.wikibooks.org/wiki/Computer_Programming" class="extiw" title="wikibooks:Computer Programming">Computer Programming</a></i> has a page on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Computer_Programming/Control" class="extiw" title="wikibooks:Computer Programming/Control">Control</a></b></i></div></div> </div> <ul><li><span class="noviewer" typeof="mw:File"><a href="/wiki/File:Commons-logo.svg" class="mw-file-description"><img alt="" src="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/20px-Commons-logo.svg.png" decoding="async" width="12" height="16" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/40px-Commons-logo.svg.png 2x" data-file-width="1024" data-file-height="1376" /></a></span> Media related to <a href="https://commons.wikimedia.org/wiki/Category:Control_flow" class="extiw" title="commons:Category:Control flow">Control flow</a> at Wikimedia Commons</li> <li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20070703050443/http://www.acm.org/classics/oct95/">Go To Statement Considered Harmful</a></li> <li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20180716171336/http://www.fortran.com/fortran/come_from.html">A Linguistic Contribution of GOTO-less Programming</a></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20090824073244/http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf">"Structured Programming with Go To Statements"</a> <span class="cs1-format">(PDF)</span>. Archived from <a rel="nofollow" class="external text" href="http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2009-08-24.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Structured+Programming+with+Go+To+Statements&amp;rft_id=http%3A%2F%2Fpplab.snu.ac.kr%2Fcourses%2Fadv_pl05%2Fpapers%2Fp261-knuth.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span>&#160;<span style="font-size: 85%;">(2.88&#160;MB)</span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.bitsavers.org/pdf/ibm/704/24-6661-2_704_Manual_1955.pdf">"IBM 704 Manual"</a> <span class="cs1-format">(PDF)</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=IBM+704+Manual&amp;rft_id=http%3A%2F%2Fwww.bitsavers.org%2Fpdf%2Fibm%2F704%2F24-6661-2_704_Manual_1955.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AControl+flow" class="Z3988"></span>&#160;<span style="font-size: 85%;">(31.4&#160;MB)</span></li></ul> <!-- NewPP limit report Parsed by mw‐web.codfw.main‐65585cc8dc‐d6dtg Cached time: 20250401004247 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.625 seconds Real time usage: 0.791 seconds Preprocessor visited node count: 7779/1000000 Post‐expand include size: 109122/2097152 bytes Template argument size: 5633/2097152 bytes Highest expansion depth: 13/100 Expensive parser function count: 42/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 151048/5000000 bytes Lua time usage: 0.272/10.000 seconds Lua memory usage: 7147067/52428800 bytes Number of Wikibase entities loaded: 1/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 619.744 1 -total 28.86% 178.840 2 Template:Reflist 14.82% 91.841 1 Template:Loop_constructs 14.60% 90.455 5 Template:Cite_book 14.25% 88.297 1 Template:Sidebar 12.49% 77.392 1 Template:Short_description 8.09% 50.160 18 Template:Cite_web 7.82% 48.461 2 Template:Pagetype 5.62% 34.809 1 Template:Citation_needed 4.93% 30.579 12 Template:Main_article --> <!-- Saved in parser cache with key enwiki:pcache:45459:|#|:idhash:canonical and timestamp 20250401004247 and revision id 1283356404. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://auth.wikimedia.org/loginwiki/wiki/Special:CentralAutoLogin/start?useformat=desktop&amp;type=1x1&amp;usesul3=1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Control_flow&amp;oldid=1283356404">https://en.wikipedia.org/w/index.php?title=Control_flow&amp;oldid=1283356404</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Categories</a>: <ul><li><a href="/wiki/Category:Control_flow" title="Category:Control flow">Control flow</a></li><li><a href="/wiki/Category:Iteration_in_programming" title="Category:Iteration in programming">Iteration in programming</a></li><li><a href="/wiki/Category:Programming_language_comparisons" title="Category:Programming language comparisons">Programming language comparisons</a></li><li><a href="/wiki/Category:Recursion" title="Category:Recursion">Recursion</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Webarchive_template_wayback_links" title="Category:Webarchive template wayback links">Webarchive template wayback links</a></li><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_is_different_from_Wikidata" title="Category:Short description is different from Wikidata">Short description is different from Wikidata</a></li><li><a href="/wiki/Category:All_articles_with_unsourced_statements" title="Category:All articles with unsourced statements">All articles with unsourced statements</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_July_2014" title="Category:Articles with unsourced statements from July 2014">Articles with unsourced statements from July 2014</a></li><li><a href="/wiki/Category:Wikipedia_articles_needing_clarification_from_November_2015" title="Category:Wikipedia articles needing clarification from November 2015">Wikipedia articles needing clarification from November 2015</a></li><li><a href="/wiki/Category:Articles_with_example_Python_(programming_language)_code" title="Category:Articles with example Python (programming language) code">Articles with example Python (programming language) code</a></li><li><a href="/wiki/Category:Commons_category_link_from_Wikidata" title="Category:Commons category link from Wikidata">Commons category link from Wikidata</a></li><li><a href="/wiki/Category:Articles_with_example_Ada_code" title="Category:Articles with example Ada code">Articles with example Ada code</a></li><li><a href="/wiki/Category:Articles_with_example_ALGOL_60_code" title="Category:Articles with example ALGOL 60 code">Articles with example ALGOL 60 code</a></li><li><a href="/wiki/Category:Articles_with_example_ALGOL_68_code" title="Category:Articles with example ALGOL 68 code">Articles with example ALGOL 68 code</a></li><li><a href="/wiki/Category:Articles_with_example_C_code" title="Category:Articles with example C code">Articles with example C code</a></li><li><a href="/wiki/Category:Articles_with_example_C%2B%2B_code" title="Category:Articles with example C++ code">Articles with example C++ code</a></li><li><a href="/wiki/Category:Articles_with_example_C_Sharp_code" title="Category:Articles with example C Sharp code">Articles with example C Sharp code</a></li><li><a href="/wiki/Category:Articles_with_example_D_code" title="Category:Articles with example D code">Articles with example D code</a></li><li><a href="/wiki/Category:Articles_with_example_Fortran_code" title="Category:Articles with example Fortran code">Articles with example Fortran code</a></li><li><a href="/wiki/Category:Articles_with_example_Haskell_code" title="Category:Articles with example Haskell code">Articles with example Haskell code</a></li><li><a href="/wiki/Category:Articles_with_example_Java_code" title="Category:Articles with example Java code">Articles with example Java code</a></li><li><a href="/wiki/Category:Articles_with_example_JavaScript_code" title="Category:Articles with example JavaScript code">Articles with example JavaScript code</a></li><li><a href="/wiki/Category:Articles_with_example_Lisp_(programming_language)_code" title="Category:Articles with example Lisp (programming language) code">Articles with example Lisp (programming language) code</a></li><li><a href="/wiki/Category:Articles_with_example_MATLAB/Octave_code" title="Category:Articles with example MATLAB/Octave code">Articles with example MATLAB/Octave code</a></li><li><a href="/wiki/Category:Articles_with_example_Pascal_code" title="Category:Articles with example Pascal code">Articles with example Pascal code</a></li><li><a href="/wiki/Category:Articles_with_example_Perl_code" title="Category:Articles with example Perl code">Articles with example Perl code</a></li><li><a href="/wiki/Category:Articles_with_example_PHP_code" title="Category:Articles with example PHP code">Articles with example PHP code</a></li><li><a href="/wiki/Category:Articles_with_example_Ruby_code" title="Category:Articles with example Ruby code">Articles with example Ruby code</a></li><li><a href="/wiki/Category:Articles_with_example_Smalltalk_code" title="Category:Articles with example Smalltalk code">Articles with example Smalltalk code</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 1 April 2025, at 00:41<span class="anonymous-show">&#160;(UTC)</span>.</li> <li id="footer-info-copyright">Text is available under the <a href="/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" title="Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License">Creative Commons Attribution-ShareAlike 4.0 License</a>; additional terms may apply. By using this site, you agree to the <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use" class="extiw" title="foundation:Special:MyLanguage/Policy:Terms of Use">Terms of Use</a> and <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy" class="extiw" title="foundation:Special:MyLanguage/Policy:Privacy policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a rel="nofollow" class="external text" href="https://wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Control_flow&amp;mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://www.wikimedia.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/static/images/footer/wikimedia-button.svg" width="84" height="29"><img src="/static/images/footer/wikimedia.svg" width="25" height="25" alt="Wikimedia Foundation" lang="en" loading="lazy"></picture></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/w/resources/assets/poweredby_mediawiki.svg" width="88" height="31"><img src="/w/resources/assets/mediawiki_compact.svg" alt="Powered by MediaWiki" lang="en" width="25" height="25" loading="lazy"></picture></a></li> </ul> </footer> </div> </div> </div> <div class="vector-header-container vector-sticky-header-container"> <div id="vector-sticky-header" class="vector-sticky-header"> <div class="vector-sticky-header-start"> <div class="vector-sticky-header-icon-start vector-button-flush-left vector-button-flush-right" aria-hidden="true"> <button class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-sticky-header-search-toggle" tabindex="-1" data-event-name="ui.vector-sticky-search-form.icon"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </button> </div> <div role="search" class="vector-search-box-vue vector-search-box-show-thumbnail vector-search-box"> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail"> <form action="/w/index.php" id="vector-sticky-search-form" class="cdx-search-input cdx-search-input--has-end-button"> <div class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia"> <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <div class="vector-sticky-header-context-bar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-sticky-header-toc" class="vector-dropdown mw-portlet mw-portlet-sticky-header-toc vector-sticky-header-toc vector-button-flush-left" > <input type="checkbox" id="vector-sticky-header-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-sticky-header-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-sticky-header-toc-label" for="vector-sticky-header-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-sticky-header-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div class="vector-sticky-header-context-bar-primary" aria-hidden="true" ><span class="mw-page-title-main">Control flow</span></div> </div> </div> <div class="vector-sticky-header-end" aria-hidden="true"> <div class="vector-sticky-header-icons"> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-talk-sticky-header" tabindex="-1" data-event-name="talk-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbles mw-ui-icon-wikimedia-speechBubbles"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-subject-sticky-header" tabindex="-1" data-event-name="subject-sticky-header"><span class="vector-icon mw-ui-icon-article mw-ui-icon-wikimedia-article"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-history-sticky-header" tabindex="-1" data-event-name="history-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-history mw-ui-icon-wikimedia-wikimedia-history"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only mw-watchlink" id="ca-watchstar-sticky-header" tabindex="-1" data-event-name="watch-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-star mw-ui-icon-wikimedia-wikimedia-star"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-edit-sticky-header" tabindex="-1" data-event-name="wikitext-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-wikiText mw-ui-icon-wikimedia-wikimedia-wikiText"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-ve-edit-sticky-header" tabindex="-1" data-event-name="ve-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-edit mw-ui-icon-wikimedia-wikimedia-edit"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-viewsource-sticky-header" tabindex="-1" data-event-name="ve-edit-protected-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-editLock mw-ui-icon-wikimedia-wikimedia-editLock"></span> <span></span> </a> </div> <div class="vector-sticky-header-buttons"> <button class="cdx-button cdx-button--weight-quiet mw-interlanguage-selector" id="p-lang-btn-sticky-header" tabindex="-1" data-event-name="ui.dropdown-p-lang-btn-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-language mw-ui-icon-wikimedia-wikimedia-language"></span> <span>33 languages</span> </button> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive" id="ca-addsection-sticky-header" tabindex="-1" data-event-name="addsection-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbleAdd-progressive mw-ui-icon-wikimedia-speechBubbleAdd-progressive"></span> <span>Add topic</span> </a> </div> <div class="vector-sticky-header-icon-end"> <div class="vector-user-links"> </div> </div> </div> </div> </div> <div class="mw-portlet mw-portlet-dock-bottom emptyPortlet" id="p-dock-bottom"> <ul> </ul> </div> <script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-65585cc8dc-7tpsn","wgBackendResponseTime":208,"wgPageParseReport":{"limitreport":{"cputime":"0.625","walltime":"0.791","ppvisitednodes":{"value":7779,"limit":1000000},"postexpandincludesize":{"value":109122,"limit":2097152},"templateargumentsize":{"value":5633,"limit":2097152},"expansiondepth":{"value":13,"limit":100},"expensivefunctioncount":{"value":42,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":151048,"limit":5000000},"entityaccesscount":{"value":1,"limit":400},"timingprofile":["100.00% 619.744 1 -total"," 28.86% 178.840 2 Template:Reflist"," 14.82% 91.841 1 Template:Loop_constructs"," 14.60% 90.455 5 Template:Cite_book"," 14.25% 88.297 1 Template:Sidebar"," 12.49% 77.392 1 Template:Short_description"," 8.09% 50.160 18 Template:Cite_web"," 7.82% 48.461 2 Template:Pagetype"," 5.62% 34.809 1 Template:Citation_needed"," 4.93% 30.579 12 Template:Main_article"]},"scribunto":{"limitreport-timeusage":{"value":"0.272","limit":"10.000"},"limitreport-memusage":{"value":7147067,"limit":52428800}},"cachereport":{"origin":"mw-web.codfw.main-65585cc8dc-d6dtg","timestamp":"20250401004247","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Control flow","url":"https:\/\/en.wikipedia.org\/wiki\/Control_flow","sameAs":"http:\/\/www.wikidata.org\/entity\/Q868299","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q868299","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2002-03-22T14:00:06Z","dateModified":"2025-04-01T00:41:29Z","headline":"order in which individual statements, instructions or function calls of an imperative program are executed or evaluated"}</script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10