CINXE.COM
Function (computer programming) - Wikipedia
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-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-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Function (computer programming) - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-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-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":"78395812-6596-43c3-8208-45abdaf1de00","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Function_(computer_programming)","wgTitle":"Function (computer programming)","wgCurRevisionId":1253066507,"wgRevisionId":1253066507,"wgArticleId":32177451,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description is different from Wikidata","Use dmy dates from April 2022","All articles with unsourced statements","Articles with unsourced statements from November 2008","Wikipedia articles needing clarification from November 2015","Articles with unsourced statements from June 2011","Articles with unsourced statements from February 2021","Articles with example C code","Source code","Holism", "Programming constructs","Subroutines"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Function_(computer_programming)","wgRelevantArticleId":32177451,"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,"wgRelatedArticlesCompat":[],"wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true, "wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q190686","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":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.cite.styles":"ready","ext.pygments":"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","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.cite.ux-enhancements","ext.pygments.view","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.growthExperiments.SuggestedEditSession","wikibase.sidebar.tracking"];</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&modules=ext.cite.styles%7Cext.pygments%2CwikimediaBadges%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <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="Function (computer programming) - 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/Function_(computer_programming)"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Function_(computer_programming)&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/Function_(computer_programming)"> <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&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.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-Function_computer_programming rootpage-Function_computer_programming 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" > <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> </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'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/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&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&returnto=Function+%28computer+programming%29" 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&returnto=Function+%28computer+programming%29" title="You're encouraged to log in; however, it'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/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&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&returnto=Function+%28computer+programming%29" 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&returnto=Function+%28computer+programming%29" title="You're encouraged to log in; however, it'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-Terminology" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Terminology"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Terminology</span> </div> </a> <ul id="toc-Terminology-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-History" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#History"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>History</span> </div> </a> <button aria-controls="toc-History-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 History subsection</span> </button> <ul id="toc-History-sublist" class="vector-toc-list"> <li id="toc-Language_support" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Language_support"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Language support</span> </div> </a> <ul id="toc-Language_support-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Libraries" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Libraries"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2</span> <span>Libraries</span> </div> </a> <ul id="toc-Libraries-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Return_by_indirect_jump" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Return_by_indirect_jump"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3</span> <span>Return by indirect jump</span> </div> </a> <ul id="toc-Return_by_indirect_jump-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Jump_to_subroutine" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Jump_to_subroutine"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.4</span> <span>Jump to subroutine</span> </div> </a> <ul id="toc-Jump_to_subroutine-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Call_stack" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Call_stack"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.5</span> <span>Call stack</span> </div> </a> <ul id="toc-Call_stack-sublist" class="vector-toc-list"> <li id="toc-Delayed_stacking" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Delayed_stacking"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.5.1</span> <span>Delayed stacking</span> </div> </a> <ul id="toc-Delayed_stacking-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </li> <li id="toc-Features" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Features"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Features</span> </div> </a> <ul id="toc-Features-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Implementations" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Implementations"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Implementations</span> </div> </a> <button aria-controls="toc-Implementations-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 Implementations subsection</span> </button> <ul id="toc-Implementations-sublist" class="vector-toc-list"> <li id="toc-General_characteristics" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#General_characteristics"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>General characteristics</span> </div> </a> <ul id="toc-General_characteristics-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Naming" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Naming"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>Naming</span> </div> </a> <ul id="toc-Naming-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Call_syntax" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Call_syntax"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3</span> <span>Call syntax</span> </div> </a> <ul id="toc-Call_syntax-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Parameters" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Parameters"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.4</span> <span>Parameters</span> </div> </a> <ul id="toc-Parameters-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Return_value" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Return_value"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.5</span> <span>Return value</span> </div> </a> <ul id="toc-Return_value-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Side_effects" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Side_effects"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.6</span> <span>Side effects</span> </div> </a> <ul id="toc-Side_effects-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Local_variables" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Local_variables"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.7</span> <span>Local variables</span> </div> </a> <ul id="toc-Local_variables-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Nested_call_–_recursion" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Nested_call_–_recursion"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.8</span> <span>Nested call – recursion</span> </div> </a> <ul id="toc-Nested_call_–_recursion-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Nested_scope" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Nested_scope"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.9</span> <span>Nested scope</span> </div> </a> <ul id="toc-Nested_scope-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Reentrancy" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Reentrancy"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.10</span> <span>Reentrancy</span> </div> </a> <ul id="toc-Reentrancy-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Overloading" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Overloading"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.11</span> <span>Overloading</span> </div> </a> <ul id="toc-Overloading-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Closure" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Closure"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.12</span> <span>Closure</span> </div> </a> <ul id="toc-Closure-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Exception_reporting" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Exception_reporting"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.13</span> <span>Exception reporting</span> </div> </a> <ul id="toc-Exception_reporting-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Call_overhead" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Call_overhead"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.14</span> <span>Call overhead</span> </div> </a> <ul id="toc-Call_overhead-sublist" class="vector-toc-list"> <li id="toc-Compiler_optimization" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Compiler_optimization"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.14.1</span> <span>Compiler optimization</span> </div> </a> <ul id="toc-Compiler_optimization-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Inlining" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Inlining"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.14.2</span> <span>Inlining</span> </div> </a> <ul id="toc-Inlining-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Sharing" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Sharing"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.15</span> <span>Sharing</span> </div> </a> <ul id="toc-Sharing-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Inter-operability" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Inter-operability"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.16</span> <span>Inter-operability</span> </div> </a> <ul id="toc-Inter-operability-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Built-in_functions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Built-in_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.17</span> <span>Built-in functions</span> </div> </a> <ul id="toc-Built-in_functions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Programming" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Programming"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Programming</span> </div> </a> <button aria-controls="toc-Programming-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 Programming subsection</span> </button> <ul id="toc-Programming-sublist" class="vector-toc-list"> <li id="toc-Trade-offs" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Trade-offs"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>Trade-offs</span> </div> </a> <ul id="toc-Trade-offs-sublist" class="vector-toc-list"> <li id="toc-Advantages" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Advantages"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1.1</span> <span>Advantages</span> </div> </a> <ul id="toc-Advantages-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Disadvantages" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Disadvantages"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1.2</span> <span>Disadvantages</span> </div> </a> <ul id="toc-Disadvantages-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Conventions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Conventions"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2</span> <span>Conventions</span> </div> </a> <ul id="toc-Conventions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Examples" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Examples"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Examples</span> </div> </a> <button aria-controls="toc-Examples-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 Examples subsection</span> </button> <ul id="toc-Examples-sublist" class="vector-toc-list"> <li id="toc-Early_BASIC" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Early_BASIC"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.1</span> <span>Early BASIC</span> </div> </a> <ul id="toc-Early_BASIC-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Small_Basic" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Small_Basic"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.2</span> <span>Small Basic</span> </div> </a> <ul id="toc-Small_Basic-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Visual_Basic" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Visual_Basic"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3</span> <span>Visual Basic</span> </div> </a> <ul id="toc-Visual_Basic-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-C_and_C++" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#C_and_C++"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.4</span> <span>C and C++</span> </div> </a> <ul id="toc-C_and_C++-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PL/I" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PL/I"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.5</span> <span>PL/I</span> </div> </a> <ul id="toc-PL/I-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Python" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Python"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.6</span> <span>Python</span> </div> </a> <ul id="toc-Python-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Prolog" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Prolog"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.7</span> <span>Prolog</span> </div> </a> <ul id="toc-Prolog-sublist" class="vector-toc-list"> </ul> </li> </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">7</span> <span>See also</span> </div> </a> <ul id="toc-See_also-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">8</span> <span>References</span> </div> </a> <ul id="toc-References-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" > <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">Function (computer programming)</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 46 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-46" 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">46 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%AF%D8%A7%D9%84%D8%A9_(%D8%A8%D8%B1%D9%85%D8%AC%D8%A9)" 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/S%C9%99tiri%C3%A7i_altproqram" title="Sətiriçi altproqram – Azerbaijani" lang="az" hreflang="az" data-title="Sətiriçi altproqram" 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-bn mw-list-item"><a href="https://bn.wikipedia.org/wiki/%E0%A6%B8%E0%A6%BE%E0%A6%AC%E0%A6%B0%E0%A7%81%E0%A6%9F%E0%A6%BF%E0%A6%A8" title="সাবরুটিন – Bangla" lang="bn" hreflang="bn" data-title="সাবরুটিন" data-language-autonym="বাংলা" data-language-local-name="Bangla" class="interlanguage-link-target"><span>বাংলা</span></a></li><li class="interlanguage-link interwiki-bg mw-list-item"><a href="https://bg.wikipedia.org/wiki/%D0%9F%D0%BE%D0%B4%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%B0" title="Подпрограма – Bulgarian" lang="bg" hreflang="bg" data-title="Подпрограма" data-language-autonym="Български" data-language-local-name="Bulgarian" class="interlanguage-link-target"><span>Български</span></a></li><li class="interlanguage-link interwiki-bs mw-list-item"><a href="https://bs.wikipedia.org/wiki/Podrutina" title="Podrutina – Bosnian" lang="bs" hreflang="bs" data-title="Podrutina" data-language-autonym="Bosanski" data-language-local-name="Bosnian" class="interlanguage-link-target"><span>Bosanski</span></a></li><li class="interlanguage-link interwiki-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Subrutina" title="Subrutina – Catalan" lang="ca" hreflang="ca" data-title="Subrutina" 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/Podprogram" title="Podprogram – Czech" lang="cs" hreflang="cs" data-title="Podprogram" 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-da mw-list-item"><a href="https://da.wikipedia.org/wiki/Subrutine" title="Subrutine – Danish" lang="da" hreflang="da" data-title="Subrutine" data-language-autonym="Dansk" data-language-local-name="Danish" class="interlanguage-link-target"><span>Dansk</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Unterprogramm" title="Unterprogramm – German" lang="de" hreflang="de" data-title="Unterprogramm" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-et mw-list-item"><a href="https://et.wikipedia.org/wiki/Alamprogramm" title="Alamprogramm – Estonian" lang="et" hreflang="et" data-title="Alamprogramm" data-language-autonym="Eesti" data-language-local-name="Estonian" class="interlanguage-link-target"><span>Eesti</span></a></li><li class="interlanguage-link interwiki-el mw-list-item"><a href="https://el.wikipedia.org/wiki/%CE%94%CE%B9%CE%B1%CE%B4%CE%B9%CE%BA%CE%B1%CF%83%CE%AF%CE%B1_(%CF%85%CF%80%CE%BF%CE%BB%CE%BF%CE%B3%CE%B9%CF%83%CF%84%CE%AD%CF%82)" title="Διαδικασία (υπολογιστές) – Greek" lang="el" hreflang="el" data-title="Διαδικασία (υπολογιστές)" data-language-autonym="Ελληνικά" data-language-local-name="Greek" class="interlanguage-link-target"><span>Ελληνικά</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Subrutina" title="Subrutina – Spanish" lang="es" hreflang="es" data-title="Subrutina" 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/Subprogramo" title="Subprogramo – Esperanto" lang="eo" hreflang="eo" data-title="Subprogramo" data-language-autonym="Esperanto" data-language-local-name="Esperanto" class="interlanguage-link-target"><span>Esperanto</span></a></li><li class="interlanguage-link interwiki-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%D8%AA%D8%A7%D8%A8%D8%B9_(%D8%B9%D9%84%D9%88%D9%85_%D8%B1%D8%A7%DB%8C%D8%A7%D9%86%D9%87)" 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/Sous-programme" title="Sous-programme – French" lang="fr" hreflang="fr" data-title="Sous-programme" 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/%ED%95%A8%EC%88%98_(%EC%BB%B4%ED%93%A8%ED%84%B0_%EA%B3%BC%ED%95%99)" 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/Potprogram" title="Potprogram – Croatian" lang="hr" hreflang="hr" data-title="Potprogram" data-language-autonym="Hrvatski" data-language-local-name="Croatian" class="interlanguage-link-target"><span>Hrvatski</span></a></li><li class="interlanguage-link interwiki-io mw-list-item"><a href="https://io.wikipedia.org/wiki/Subprogramo" title="Subprogramo – Ido" lang="io" hreflang="io" data-title="Subprogramo" data-language-autonym="Ido" data-language-local-name="Ido" class="interlanguage-link-target"><span>Ido</span></a></li><li class="interlanguage-link interwiki-id mw-list-item"><a href="https://id.wikipedia.org/wiki/Subrutin" title="Subrutin – Indonesian" lang="id" hreflang="id" data-title="Subrutin" data-language-autonym="Bahasa Indonesia" data-language-local-name="Indonesian" class="interlanguage-link-target"><span>Bahasa Indonesia</span></a></li><li class="interlanguage-link interwiki-is mw-list-item"><a href="https://is.wikipedia.org/wiki/Undirforrit" title="Undirforrit – Icelandic" lang="is" hreflang="is" data-title="Undirforrit" data-language-autonym="Íslenska" data-language-local-name="Icelandic" class="interlanguage-link-target"><span>Íslenska</span></a></li><li class="interlanguage-link interwiki-he mw-list-item"><a href="https://he.wikipedia.org/wiki/%D7%A9%D7%92%D7%A8%D7%94_(%D7%AA%D7%9B%D7%A0%D7%95%D7%AA)" 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%9A%D3%A9%D0%BC%D0%B5%D0%BA%D1%88%D1%96_%D0%B1%D0%B0%D2%93%D0%B4%D0%B0%D1%80%D0%BB%D0%B0%D0%BC%D0%B0" 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-sw mw-list-item"><a href="https://sw.wikipedia.org/wiki/Utaratibu_(uhandisi_wa_programu)" title="Utaratibu (uhandisi wa programu) – Swahili" lang="sw" hreflang="sw" data-title="Utaratibu (uhandisi wa programu)" data-language-autonym="Kiswahili" data-language-local-name="Swahili" class="interlanguage-link-target"><span>Kiswahili</span></a></li><li class="interlanguage-link interwiki-lmo mw-list-item"><a href="https://lmo.wikipedia.org/wiki/Sota-programa" title="Sota-programa – Lombard" lang="lmo" hreflang="lmo" data-title="Sota-programa" data-language-autonym="Lombard" data-language-local-name="Lombard" class="interlanguage-link-target"><span>Lombard</span></a></li><li class="interlanguage-link interwiki-hu mw-list-item"><a href="https://hu.wikipedia.org/wiki/F%C3%BCggv%C3%A9ny_(programoz%C3%A1s)" title="Függvény (programozás) – Hungarian" lang="hu" hreflang="hu" data-title="Függvény (programozás)" data-language-autonym="Magyar" data-language-local-name="Hungarian" class="interlanguage-link-target"><span>Magyar</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Subprogramma" title="Subprogramma – Dutch" lang="nl" hreflang="nl" data-title="Subprogramma" 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/%E3%82%B5%E3%83%96%E3%83%AB%E3%83%BC%E3%83%81%E3%83%B3" 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/Delrutine" title="Delrutine – Norwegian Bokmål" lang="nb" hreflang="nb" data-title="Delrutine" 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-mhr mw-list-item"><a href="https://mhr.wikipedia.org/wiki/%D0%98%D0%B3%D1%8B%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B5" title="Игыпрограмме – Eastern Mari" lang="mhr" hreflang="mhr" data-title="Игыпрограмме" data-language-autonym="Олык марий" data-language-local-name="Eastern Mari" class="interlanguage-link-target"><span>Олык марий</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Podprogram" title="Podprogram – Polish" lang="pl" hreflang="pl" data-title="Podprogram" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-pt badge-Q70893996 mw-list-item" title=""><a href="https://pt.wikipedia.org/wiki/Sub-rotina" title="Sub-rotina – Portuguese" lang="pt" hreflang="pt" data-title="Sub-rotina" 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%D0%B4%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B0" 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-simple mw-list-item"><a href="https://simple.wikipedia.org/wiki/Subroutine" title="Subroutine – Simple English" lang="en-simple" hreflang="en-simple" data-title="Subroutine" data-language-autonym="Simple English" data-language-local-name="Simple English" class="interlanguage-link-target"><span>Simple English</span></a></li><li class="interlanguage-link interwiki-sk mw-list-item"><a href="https://sk.wikipedia.org/wiki/Podprogram" title="Podprogram – Slovak" lang="sk" hreflang="sk" data-title="Podprogram" data-language-autonym="Slovenčina" data-language-local-name="Slovak" class="interlanguage-link-target"><span>Slovenčina</span></a></li><li class="interlanguage-link interwiki-sl mw-list-item"><a href="https://sl.wikipedia.org/wiki/Podprogram" title="Podprogram – Slovenian" lang="sl" hreflang="sl" data-title="Podprogram" data-language-autonym="Slovenščina" data-language-local-name="Slovenian" class="interlanguage-link-target"><span>Slovenščina</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/%D0%9F%D0%BE%D1%82%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%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/Funkcija_(programiranje)" title="Funkcija (programiranje) – Serbo-Croatian" lang="sh" hreflang="sh" data-title="Funkcija (programiranje)" data-language-autonym="Srpskohrvatski / српскохрватски" data-language-local-name="Serbo-Croatian" class="interlanguage-link-target"><span>Srpskohrvatski / српскохрватски</span></a></li><li class="interlanguage-link interwiki-fi mw-list-item"><a href="https://fi.wikipedia.org/wiki/Aliohjelma" title="Aliohjelma – Finnish" lang="fi" hreflang="fi" data-title="Aliohjelma" data-language-autonym="Suomi" data-language-local-name="Finnish" class="interlanguage-link-target"><span>Suomi</span></a></li><li class="interlanguage-link interwiki-tl mw-list-item"><a href="https://tl.wikipedia.org/wiki/Punsiyon_(agham_pangkompyuter)" title="Punsiyon (agham pangkompyuter) – Tagalog" lang="tl" hreflang="tl" data-title="Punsiyon (agham pangkompyuter)" data-language-autonym="Tagalog" data-language-local-name="Tagalog" class="interlanguage-link-target"><span>Tagalog</span></a></li><li class="interlanguage-link interwiki-ta mw-list-item"><a href="https://ta.wikipedia.org/wiki/%E0%AE%9A%E0%AF%86%E0%AE%AF%E0%AE%B2%E0%AF%8D%E0%AE%95%E0%AF%82%E0%AE%B1%E0%AF%81_(%E0%AE%A8%E0%AE%BF%E0%AE%B0%E0%AE%B2%E0%AE%BE%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%AE%E0%AF%8D)" 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%B8%8B%E0%B8%B1%E0%B8%9A%E0%B8%A3%E0%B8%B9%E0%B8%97%E0%B8%B5%E0%B8%99" 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-tr mw-list-item"><a href="https://tr.wikipedia.org/wiki/Altyordam" title="Altyordam – Turkish" lang="tr" hreflang="tr" data-title="Altyordam" data-language-autonym="Türkçe" data-language-local-name="Turkish" class="interlanguage-link-target"><span>Türkçe</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%9F%D1%96%D0%B4%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%B0" 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-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/Ch%C6%B0%C6%A1ng_tr%C3%ACnh_con" title="Chương trình con – Vietnamese" lang="vi" hreflang="vi" data-title="Chương trình con" 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/%E5%AD%90%E7%A8%8B%E5%BC%8F" 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/%E5%AD%90%E7%A8%8B%E5%BA%8F" 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/Q190686#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/Function_(computer_programming)" 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:Function_(computer_programming)" 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/Function_(computer_programming)"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Function_(computer_programming)&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=Function_(computer_programming)&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/Function_(computer_programming)"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Function_(computer_programming)&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=Function_(computer_programming)&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/Function_(computer_programming)" 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/Function_(computer_programming)" 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="/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Function_(computer_programming)&oldid=1253066507" 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=Function_(computer_programming)&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&page=Function_%28computer_programming%29&id=1253066507&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&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFunction_%28computer_programming%29"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFunction_%28computer_programming%29"><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&page=Function_%28computer_programming%29&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=Function_(computer_programming)&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-wikifunctions mw-list-item"><a href="https://www.wikifunctions.org/wiki/Z8" hreflang="en"><span>Wikifunctions</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/Q190686" 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">Sequence of program instructions invokable by other software</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">For other uses, see <a href="/wiki/Function_(disambiguation)" class="mw-redirect mw-disambig" title="Function (disambiguation)">Function</a>.</div> <p> <span class="anchor" id="SUBROUTINE_DEFINITION"></span> </p><p>In <a href="/wiki/Computer_programming" title="Computer programming">computer programming</a>, a <b>function</b> (also <b>procedure</b>, <b>method</b>, <b>subroutine</b>, <b>routine</b>, or <b>subprogram</b>) is a <b>callable unit</b><sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> of <a href="/wiki/Software_logic" class="mw-redirect" title="Software logic">software logic</a> that has a well-defined <a href="/wiki/Interface_(computing)" title="Interface (computing)">interface</a> and <a href="/wiki/Behavior" title="Behavior">behavior</a> and can be invoked multiple times. </p><p>Callable units provide a powerful programming tool.<sup id="cite_ref-knuth1_2-0" class="reference"><a href="#cite_note-knuth1-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> The primary purpose is to allow for the decomposition of a large and/or complicated problem into chunks that have relatively low <a href="/wiki/Cognitive_load" title="Cognitive load">cognitive load</a> and to assign the chunks meaningful names (unless they are anonymous). Judicious application can reduce the cost of developing and maintaining software, while increasing its quality and reliability.<sup id="cite_ref-structprog_3-0" class="reference"><a href="#cite_note-structprog-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> </p><p>Callable units are present at multiple levels of <a href="/wiki/Abstraction" title="Abstraction">abstraction</a> in the programming environment. For example, a <a href="/wiki/Programmer" title="Programmer">programmer</a> may write a function in <a href="/wiki/Source_code" title="Source code">source code</a> that is compiled to machine code that implements similar <a href="/wiki/Semantics" title="Semantics">semantics</a>. There is a callable unit in the source code and an associated one in the machine code, but they are different kinds of callable units – with different implications and features. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Terminology">Terminology</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=1" title="Edit section: Terminology"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The meaning of each callable term (function, procedure, method, ...) is, in fact, different. They are not <a href="/wiki/Synonymous" class="mw-redirect" title="Synonymous">synonymous</a>. Nevertheless, they each add a capability to programming that has commonality. </p><p>The term used tends to reflect the context in which it is used – usually based on the language being used. For example: </p> <ul><li><i>Subprogram</i>, <i>routine</i> and <i>subroutine</i> were more commonly used in the past but are less common today</li></ul> <ul><li><i>Routine</i> and <i>subroutine</i> have essentially the same meaning but describe a hierarchical relationship, much like how a subdirectory is structurally subordinate to its parent <a href="/wiki/Directory_(computing)" title="Directory (computing)">directory</a>; <i>program</i> and <i>subprogram</i> are similarly related</li></ul> <ul><li>Some consider <i>function</i> to imply a <a href="/wiki/Function_(mathematics)" title="Function (mathematics)">mathematical function</a>, having no side-effects, but in many contexts <i>function</i> refers to any callable</li></ul> <ul><li>In the context of <a href="/wiki/Visual_Basic" title="Visual Basic">Visual Basic</a> and <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Sub</code>, short for <i>subroutine</i> or <i>subprocedure</i>, is the name of a callable that does not return a value whereas a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Function</code> does return a value</li></ul> <ul><li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a> languages such as <a href="/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> and <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> use the term <i><a href="/wiki/Method_(computer_programming)" title="Method (computer programming)">method</a></i> to refer to a member function of an <a href="/wiki/Object_(computer_science)" title="Object (computer science)">object</a></li></ul> <div class="mw-heading mw-heading2"><h2 id="History">History</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=2" title="Edit section: History"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The idea of a callable unit was initially conceived by <a href="/wiki/John_Mauchly" title="John Mauchly">John Mauchly</a> and <a href="/wiki/Kathleen_Antonelli" title="Kathleen Antonelli">Kathleen Antonelli</a> during their work on <a href="/wiki/ENIAC" title="ENIAC">ENIAC</a> and recorded in a January 1947 Harvard symposium on "Preparation of Problems for <a href="/wiki/EDVAC" title="EDVAC">EDVAC</a>-type Machines."<sup id="cite_ref-mauchly0_4-0" class="reference"><a href="#cite_note-mauchly0-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> <a href="/wiki/Maurice_Wilkes" title="Maurice Wilkes">Maurice Wilkes</a>, <a href="/wiki/David_Wheeler_(British_computer_scientist)" class="mw-redirect" title="David Wheeler (British computer scientist)">David Wheeler</a>, and <a href="/wiki/Stanley_Gill" title="Stanley Gill">Stanley Gill</a> are generally credited with the formal invention of this concept, which they termed a <i>closed sub-routine</i>,<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> contrasted with an <i>open subroutine</i> or <a href="/wiki/Macro_(computer_science)" title="Macro (computer science)">macro</a>.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> However, <a href="/wiki/Alan_Turing" title="Alan Turing">Alan Turing</a> had discussed subroutines in a paper of 1945 on design proposals for the NPL <a href="/wiki/Automatic_Computing_Engine" title="Automatic Computing Engine">ACE</a>, going so far as to invent the concept of a <a href="/wiki/Call_stack" title="Call stack">return address stack</a>.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> </p><p>The idea of a subroutine was worked out after computing machines had already existed for some time. The arithmetic and conditional jump instructions were planned ahead of time and have changed relatively little, but the special instructions used for procedure calls have changed greatly over the years. The earliest computers and microprocessors, such as the <a href="/wiki/Manchester_Baby" title="Manchester Baby">Manchester Baby</a> and the <a href="/wiki/RCA_1802" title="RCA 1802">RCA 1802</a>, did not have a single subroutine call instruction. Subroutines could be implemented, but they required programmers to use the call sequence—a series of instructions—at each <a href="/wiki/Call_site" title="Call site">call site</a>. </p><p>Subroutines were implemented in <a href="/wiki/Konrad_Zuse" title="Konrad Zuse">Konrad Zuse</a>'s <a href="/wiki/Z4_(computer)" title="Z4 (computer)">Z4</a> in 1945. </p><p>In 1945, <a href="/wiki/Alan_M._Turing" class="mw-redirect" title="Alan M. Turing">Alan M. Turing</a> used the terms "bury" and "unbury" as a means of calling and returning from subroutines.<sup id="cite_ref-Turing_1945_9-0" class="reference"><a href="#cite_note-Turing_1945-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Carpenter_1977_10-0" class="reference"><a href="#cite_note-Carpenter_1977-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> </p><p>In January 1947 John Mauchly presented general notes at 'A Symposium of Large Scale Digital Calculating Machinery' under the joint sponsorship of Harvard University and the Bureau of Ordnance, United States Navy. Here he discusses serial and parallel operation suggesting </p> <style data-mw-deduplicate="TemplateStyles:r1244412712">.mw-parser-output .templatequote{overflow:hidden;margin:1em 0;padding:0 32px}.mw-parser-output .templatequotecite{line-height:1.5em;text-align:left;margin-top:0}@media(min-width:500px){.mw-parser-output .templatequotecite{padding-left:1.6em}}</style><blockquote class="templatequote"><p>...the structure of the machine need not be complicated one bit. It is possible, since all the logical characteristics essential to this procedure are available, to evolve a coding instruction for placing the subroutines in the memory at places known to the machine, and in such a way that they may easily be called into use.</p><div class="paragraphbreak" style="margin-top:0.5em"></div><p>In other words, one can designate subroutine A as division and subroutine B as complex multiplication and subroutine C as the evaluation of a standard error of a sequence of numbers, and so on through the list of subroutines needed for a particular problem. ... All these subroutines will then be stored in the machine, and all one needs to do is make a brief reference to them by number, as they are indicated in the coding.<sup id="cite_ref-mauchly0_4-1" class="reference"><a href="#cite_note-mauchly0-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup></p></blockquote> <p><a href="/wiki/Kathleen_Antonelli" title="Kathleen Antonelli">Kay McNulty</a> had worked closely with John Mauchly on the <a href="/wiki/ENIAC" title="ENIAC">ENIAC</a> team and developed an idea for subroutines for the <a href="/wiki/ENIAC" title="ENIAC">ENIAC</a> computer she was programming during World War II.<sup id="cite_ref-:0_11-0" class="reference"><a href="#cite_note-:0-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> She and the other ENIAC programmers used the subroutines to help calculate missile trajectories.<sup id="cite_ref-:0_11-1" class="reference"><a href="#cite_note-:0-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> </p><p><a href="/wiki/Herman_Goldstine" title="Herman Goldstine">Goldstine</a> and <a href="/wiki/John_von_Neumann" title="John von Neumann">von Neumann</a> wrote a paper dated 16 August 1948 discussing the use of subroutines.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> </p><p>Some very early computers and microprocessors, such as the <a href="/wiki/IBM_1620" title="IBM 1620">IBM 1620</a>, the <a href="/wiki/Intel_4004" title="Intel 4004">Intel 4004</a> and <a href="/wiki/Intel_8008" title="Intel 8008">Intel 8008</a>, and the <a href="/wiki/PIC_microcontroller" class="mw-redirect" title="PIC microcontroller">PIC microcontrollers</a>, have a single-instruction subroutine call that uses a dedicated hardware stack to store return addresses—such hardware supports only a few levels of subroutine nesting, but can support recursive subroutines. Machines before the mid-1960s—such as the <a href="/wiki/UNIVAC_I" title="UNIVAC I">UNIVAC I</a>, the <a href="/wiki/PDP-1" title="PDP-1">PDP-1</a>, and the <a href="/wiki/IBM_1130" title="IBM 1130">IBM 1130</a>—typically use a <a href="/wiki/Calling_convention" title="Calling convention">calling convention</a> which saved the instruction counter in the first memory location of the called subroutine. This allows arbitrarily deep levels of subroutine nesting but does not support recursive subroutines. The <a href="/wiki/IBM_System/360" title="IBM System/360">IBM System/360</a> had a subroutine call instruction that placed the saved instruction counter value into a general-purpose register; this can be used to support arbitrarily deep subroutine nesting and recursive subroutines. The Burroughs <a href="/wiki/B5000" class="mw-redirect" title="B5000">B5000</a><sup id="cite_ref-B5000-21005_13-0" class="reference"><a href="#cite_note-B5000-21005-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> (1961) is one of the first computers to store subroutine return data on a stack. </p><p>The DEC <a href="/wiki/PDP-6" title="PDP-6">PDP-6</a><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> (1964) is one of the first accumulator-based machines to have a subroutine call instruction that saved the return address in a stack addressed by an accumulator or index register. The later <a href="/wiki/PDP-10" title="PDP-10">PDP-10</a> (1966), <a href="/wiki/PDP-11" title="PDP-11">PDP-11</a> (1970) and <a href="/wiki/VAX-11" title="VAX-11">VAX-11</a> (1976) lines followed suit; this feature also supports both arbitrarily deep subroutine nesting and recursive subroutines.<sup id="cite_ref-Steele_15-0" class="reference"><a href="#cite_note-Steele-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Language_support">Language support</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=3" title="Edit section: Language support"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the very early assemblers, subroutine support was limited. Subroutines were not explicitly separated from each other or from the main program, and indeed the source code of a subroutine could be interspersed with that of other subprograms. Some assemblers would offer predefined <a href="/wiki/Macro_(computer_science)" title="Macro (computer science)">macros</a> to generate the call and return sequences. By the 1960s, assemblers usually had much more sophisticated support for both inline and separately assembled subroutines that could be linked together. </p><p>One of the first programming languages to support user-written subroutines and functions was <a href="/wiki/Fortran#FORTRAN_II" title="Fortran">FORTRAN II</a>. The IBM FORTRAN II compiler was released in 1958. <a href="/wiki/ALGOL_58" title="ALGOL 58">ALGOL 58</a> and other early programming languages also supported procedural programming. </p> <div class="mw-heading mw-heading3"><h3 id="Libraries">Libraries</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=4" title="Edit section: Libraries"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Even with this cumbersome approach, subroutines proved very useful. They allowed the use of the same code in many different programs. Memory was a very scarce resource on early computers, and subroutines allowed significant savings in the size of programs. </p><p>Many early computers loaded the program instructions into memory from a <a href="/wiki/Punched_tape" title="Punched tape">punched paper tape</a>. Each subroutine could then be provided by a separate piece of tape, loaded or spliced before or after the main program (or "mainline"<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>); and the same subroutine tape could then be used by many different programs. A similar approach was used in computers that loaded program instructions from <a href="/wiki/Punched_card" title="Punched card">punched cards</a>. The name <i>subroutine library</i> originally meant a library, in the literal sense, which kept indexed collections of tapes or decks of cards for collective use. </p> <div class="mw-heading mw-heading3"><h3 id="Return_by_indirect_jump">Return by indirect jump</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=5" title="Edit section: Return by indirect jump"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>To remove the need for <a href="/wiki/Self-modifying_code" title="Self-modifying code">self-modifying code</a>, computer designers eventually provided an <i><a href="/wiki/Indirect_branch" title="Indirect branch">indirect jump</a></i> instruction, whose operand, instead of being the <a href="/wiki/Return_statement" title="Return statement">return address</a> itself, was the location of a variable or <a href="/wiki/Processor_register" title="Processor register">processor register</a> containing the return address. </p><p>On those computers, instead of modifying the function's return jump, the calling program would store the return address in a variable so that when the function completed, it would execute an indirect jump that would direct execution to the location given by the predefined variable. </p> <div class="mw-heading mw-heading3"><h3 id="Jump_to_subroutine">Jump to subroutine</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=6" title="Edit section: Jump to subroutine"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Another advance was the <i>jump to subroutine</i> instruction, which combined the saving of the return address with the calling jump, thereby minimizing <a href="/wiki/Computational_overhead" class="mw-redirect" title="Computational overhead">overhead</a> significantly. </p><p>In the IBM <a href="/wiki/System/360" class="mw-redirect" title="System/360">System/360</a>, for example, the branch instructions BAL or BALR, designed for procedure calling, would save the return address in a processor register specified in the instruction, by convention register 14. To return, the subroutine had only to execute an indirect branch instruction (BR) through that register. If the subroutine needed that register for some other purpose (such as calling another subroutine), it would save the register's contents to a private memory location or a register <a href="/wiki/Stack_(data_structure)" class="mw-redirect" title="Stack (data structure)">stack</a>. </p><p>In systems such as the <a href="/wiki/HP_2100" title="HP 2100">HP 2100</a>, the JSB instruction would perform a similar task, except that the return address was stored in the memory location that was the target of the branch. Execution of the procedure would actually begin at the next memory location. In the HP 2100 assembly language, one would write, for example </p> <div class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr"><pre><span></span>... JSB MYSUB (Calls subroutine MYSUB.) BB ... (Will return here after MYSUB is done.) </pre></div> <p>to call a subroutine called MYSUB from the main program. The subroutine would be coded as </p> <div class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr"><pre><span></span>MYSUB NOP (Storage for MYSUB's return address.) AA ... (Start of MYSUB's body.) ... JMP MYSUB,I (Returns to the calling program.) </pre></div> <p>The JSB instruction placed the address of the NEXT instruction (namely, BB) into the location specified as its operand (namely, MYSUB), and then branched to the NEXT location after that (namely, AA = MYSUB + 1). The subroutine could then return to the main program by executing the indirect jump JMP MYSUB, I which branched to the location stored at location MYSUB. </p><p>Compilers for Fortran and other languages could easily make use of these instructions when available. This approach supported multiple levels of calls; however, since the return address, parameters, and return values of a subroutine were assigned fixed memory locations, it did not allow for recursive calls. </p><p>Incidentally, a similar method was used by <a href="/wiki/Lotus_1-2-3" title="Lotus 1-2-3">Lotus 1-2-3</a>, in the early 1980s, to discover the recalculation dependencies in a spreadsheet. Namely, a location was reserved in each cell to store the <i>return</i> address. Since <a href="/wiki/Circular_reference" title="Circular reference">circular references</a> are not allowed for natural recalculation order, this allows a tree walk without reserving space for a stack in memory, which was very limited on small computers such as the <a href="/wiki/IBM_PC" class="mw-redirect" title="IBM PC">IBM PC</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Call_stack">Call stack</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=7" title="Edit section: Call stack"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most modern implementations of a function call use a <a href="/wiki/Call_stack" title="Call stack">call stack</a>, a special case of the <a href="/wiki/Stack_(data_structure)" class="mw-redirect" title="Stack (data structure)">stack data structure</a>, to implement function calls and returns. Each procedure call creates a new entry, called a <i>stack frame</i>, at the top of the stack; when the procedure returns, its stack frame is deleted from the stack, and its space may be used for other procedure calls. Each stack frame contains the <i>private data</i> of the corresponding call, which typically includes the procedure's parameters and internal variables, and the return address. </p><p>The call sequence can be implemented by a sequence of ordinary instructions (an approach still used in <a href="/wiki/Reduced_instruction_set_computing" class="mw-redirect" title="Reduced instruction set computing">reduced instruction set computing</a> (RISC) and <a href="/wiki/Very_long_instruction_word" title="Very long instruction word">very long instruction word</a> (VLIW) architectures), but many traditional machines designed since the late 1960s have included special instructions for that purpose. </p><p>The call stack is usually implemented as a contiguous area of memory. It is an arbitrary design choice whether the bottom of the stack is the lowest or highest address within this area, so that the stack may grow forwards or backwards in memory; however, many architectures chose the latter.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (November 2008)">citation needed</span></a></i>]</sup> </p><p>Some designs, notably some <a href="/wiki/Forth_(programming_language)" title="Forth (programming language)">Forth</a> implementations, used two separate stacks, one mainly for control information (like return addresses and loop counters) and the other for data. The former was, or worked like, a call stack and was only indirectly accessible to the programmer through other language constructs while the latter was more directly accessible. </p><p>When stack-based procedure calls were first introduced, an important motivation was to save precious memory.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (November 2008)">citation needed</span></a></i>]</sup> With this scheme, the compiler does not have to reserve separate space in memory for the private data (parameters, return address, and local variables) of each procedure. At any moment, the stack contains only the private data of the calls that are currently <i>active</i> (namely, which have been called but haven't returned yet). Because of the ways in which programs were usually assembled from libraries, it was (and still is) not uncommon to find programs that include thousands of functions, of which only a handful are active at any given moment.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (November 2008)">citation needed</span></a></i>]</sup> For such programs, the call stack mechanism could save significant amounts of memory. Indeed, the call stack mechanism can be viewed as the earliest and simplest method for <a href="/wiki/Garbage_collection_(computer_science)" title="Garbage collection (computer science)">automatic memory management</a>. </p><p>However, another advantage of the call stack method is that it allows <a href="/wiki/Recursion_(computer_science)" title="Recursion (computer science)">recursive function calls</a>, since each nested call to the same procedure gets a separate instance of its private data. </p><p>In a <a href="/wiki/Thread_(computer_science)" class="mw-redirect" title="Thread (computer science)">multi-threaded</a> environment, there is generally more than one stack.<sup id="cite_ref-ButtlarFarrellNichols1996_17-0" class="reference"><a href="#cite_note-ButtlarFarrellNichols1996-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup> An environment that fully supports <a href="/wiki/Coroutine" title="Coroutine">coroutines</a> or <a href="/wiki/Lazy_evaluation" title="Lazy evaluation">lazy evaluation</a> may use data structures other than stacks to store their activation records. </p> <div class="mw-heading mw-heading4"><h4 id="Delayed_stacking">Delayed stacking <span class="anchor" id="Leaf_procedure"></span><span class="anchor" id="Leaf_function"></span></h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=8" title="Edit section: Delayed stacking"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>One disadvantage of the call stack mechanism is the increased cost of a procedure call and its matching return.<sup class="noprint Inline-Template" style="margin-left:0.1em; white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Please_clarify" title="Wikipedia:Please clarify"><span title="increased relative to what? (November 2015)">clarification needed</span></a></i>]</sup> The extra cost includes incrementing and decrementing the stack pointer (and, in some architectures, checking for <a href="/wiki/Stack_overflow" title="Stack overflow">stack overflow</a>), and accessing the local variables and parameters by frame-relative addresses, instead of absolute addresses. The cost may be realized in increased execution time, or increased processor complexity, or both. </p><p>This overhead is most obvious and objectionable in <i>leaf procedures</i> or <i>leaf functions</i>, which return without making any procedure calls themselves.<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup> To reduce that overhead, many modern compilers try to delay the use of a call stack until it is really needed.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (June 2011)">citation needed</span></a></i>]</sup> For example, the call of a procedure <i>P</i> may store the return address and parameters of the called procedure in certain processor registers, and transfer control to the procedure's body by a simple jump. If the procedure <i>P</i> returns without making any other call, the call stack is not used at all. If <i>P</i> needs to call another procedure <i>Q</i>, it will then use the call stack to save the contents of any registers (such as the return address) that will be needed after <i>Q</i> returns. </p> <div class="mw-heading mw-heading2"><h2 id="Features">Features</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=9" title="Edit section: Features"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In general, a callable unit is a list of instructions that, starting at the first instruction, executes sequentially except as directed via its internal logic. It can be invoked (called) many times during the <a href="/wiki/Execution_(computing)" title="Execution (computing)">execution</a> of a program. Execution continues at the next instruction after the call instruction when it <a href="/wiki/Return_statement" title="Return statement">returns</a> control. </p> <div class="mw-heading mw-heading2"><h2 id="Implementations">Implementations</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=10" title="Edit section: Implementations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The features of <a href="/wiki/Implementation" title="Implementation">implementations</a> of callable units evolved over time and varies by context. This section describes features of the various common implementations. </p> <div class="mw-heading mw-heading3"><h3 id="General_characteristics">General characteristics</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=11" title="Edit section: General characteristics"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most modern programming languages provide features to define and call functions, including <a href="/wiki/Syntax_(programming_languages)" title="Syntax (programming languages)">syntax</a> for accessing such features, including: </p> <ul><li>Delimit the implementation of a function from the rest of the program</li> <li>Assign an <a href="/wiki/Identifier" title="Identifier">identifier</a>, name, to a function</li> <li>Define <a href="/wiki/Formal_parameters" class="mw-redirect" title="Formal parameters">formal parameters</a> with a name and <a href="/wiki/Data_type" title="Data type">data type</a> for each</li> <li>Assign a <a href="/wiki/Data_type" title="Data type">data type</a> to the return value, if any</li> <li>Specify a return value in the function body</li> <li>Call a function</li> <li>Provide <a href="/wiki/Actual_parameters" class="mw-redirect" title="Actual parameters">actual parameters</a> that correspond to a called function's formal parameters</li> <li><a href="/wiki/Return_statement" title="Return statement">Return</a> control to the caller at the point of call</li> <li>Consume the return value in the caller</li> <li>Dispose of the values returned by a call</li> <li>Provide a private <a href="/wiki/Scope_(computer_science)" title="Scope (computer science)">naming scope</a> for variables</li> <li>Identify variables outside the function that are accessible within it</li> <li>Propagate an <a href="/wiki/Exception_handling" title="Exception handling">exceptional condition</a> out of a function and to handle it in the calling context</li> <li>Package functions into a container such as <a href="/wiki/Modular_programming" title="Modular programming">module</a>, <a href="/wiki/Library_(computing)" title="Library (computing)">library</a>, <a href="/wiki/Object_(computer_science)" title="Object (computer science)">object</a>, or <a href="/wiki/Class_(computer_programming)" title="Class (computer programming)">class</a></li></ul> <div class="mw-heading mw-heading3"><h3 id="Naming">Naming</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=12" title="Edit section: Naming"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some languages, such as <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>, <a href="/wiki/Fortran" title="Fortran">Fortran</a>, <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a> and many <a href="/wiki/Dialect_(computing)" class="mw-redirect" title="Dialect (computing)">dialects</a> of <a href="/wiki/BASIC" title="BASIC">BASIC</a>, use a different name for a callable unit that returns a value (<i>function</i> or <i>subprogram</i>) vs. one that does not (<i>subroutine</i> or <i>procedure</i>). Other languages, such as <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/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> and <a href="/wiki/Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a>, use only one name for a callable unit, <i>function</i>. The C-family languages use the keyword <code>void</code> to indicate no return value. </p> <div class="mw-heading mw-heading3"><h3 id="Call_syntax">Call syntax</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=13" title="Edit section: Call syntax"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If declared to return a value, a call can be embedded in an <a href="/wiki/Expression_(programming)" class="mw-redirect" title="Expression (programming)">expression</a> in order to consume the return value. For example, a square root callable unit might be called like <code>y = sqrt(x)</code>. </p><p>A callable unit that does not return a value is called as a stand-alone <a href="/wiki/Statement_(computer_science)" title="Statement (computer science)">statement</a> like <code>print("hello")</code>. This syntax can also be used for a callable unit that returns a value, but the return value will be ignored. </p><p>Some older languages require a keyword for calls that do not consume a return value, like <code>CALL print("hello")</code>. </p> <div class="mw-heading mw-heading3"><h3 id="Parameters">Parameters</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=14" title="Edit section: Parameters"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most implementations, especially in modern languages, support <a href="/wiki/Parameter_(computer_science)" class="mw-redirect" title="Parameter (computer science)">parameters</a> which the callable declares as <i>formal parameters</i>. A caller passes <i>actual parameters</i>, a.k.a. <i>arguments</i>, to match. Different programming languages provide different conventions for passing arguments. </p> <table class="wikitable"> <tbody><tr> <th>Convention</th> <th>Description</th> <th>Used in </th></tr> <tr> <td><a href="/wiki/Call_by_value" class="mw-redirect" title="Call by value">by value</a></td> <td>A copy of the argment is passed</td> <td>Default in most Algol-like languages after <a href="/wiki/Algol_60" class="mw-redirect" title="Algol 60">Algol 60</a>, such as Pascal, Delphi, Simula, CPL, PL/M, Modula, Oberon, Ada, and many others including C, C++ and Java </td></tr> <tr> <td><a href="/wiki/Call_by_reference" class="mw-redirect" title="Call by reference">by reference</a></td> <td>A reference to the argument is passed; typically its address</td> <td>Selectable in most Algol-like languages after <a href="/wiki/Algol_60" class="mw-redirect" title="Algol 60">Algol 60</a>, such as Algol 68, Pascal, Delphi, Simula, CPL, PL/M, Modula, Oberon, Ada, and many others including C++, Fortran, PL/I </td></tr> <tr> <td><a href="/wiki/Call_by_result" class="mw-redirect" title="Call by result">by result</a></td> <td>The value computed during the call is copied to the argument on return</td> <td>Ada OUT parameters </td></tr> <tr> <td><a href="/wiki/Call_by_value-result" class="mw-redirect" title="Call by value-result">by value-result</a></td> <td>A copy of the argument is passed in and the value computed during the call is copied to the argument on return</td> <td>Algol, <a href="/wiki/Swift_(programming_language)" title="Swift (programming language)">Swift</a> in-out parameters </td></tr> <tr> <td><a href="/wiki/Call_by_name" class="mw-redirect" title="Call by name">by name</a></td> <td>Like a macro – replace the parameters with the unevaluated argument expressions, then evaluate the argument in the context of the caller every time that the callable uses the parameter</td> <td>Algol, <a href="/wiki/Scala_(programming_language)" title="Scala (programming language)">Scala</a> </td></tr> <tr> <td>by constant value</td> <td>Like by-value except that the parameter is treated as a constant</td> <td>PL/I NONASSIGNABLE parameters, Ada IN parameters </td></tr></tbody></table> <div class="mw-heading mw-heading3"><h3 id="Return_value">Return value</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=15" title="Edit section: Return value"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In some languages, such as BASIC, a callable has different syntax (i.e. keyword) for a callable that returns a value vs. one that does not. In other languages, the syntax is the same regardless. In some of these languages an extra keyword is used to declare no return value; for example <code>void</code> in C, C++ and C#. In some languages, such as Python, the difference is whether the body contains a return statement with a value, and a particular callable may return with or without a value based on control flow. </p> <div class="mw-heading mw-heading3"><h3 id="Side_effects">Side effects</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=16" title="Edit section: Side effects"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In many contexts, a callable may have <a href="/wiki/Side-effect_(computer_science)" class="mw-redirect" title="Side-effect (computer science)">side effect</a> behavior such as modifying passed or global data, reading from or writing to a <a href="/wiki/Peripheral_device" class="mw-redirect" title="Peripheral device">peripheral device</a>, accessing a <a href="/wiki/Computer_file" title="Computer file">file</a>, halting the program or the machine, or temporarily pausing program execution. </p><p>Side effects are considered undesireble by <a href="/wiki/Robert_C._Martin" title="Robert C. Martin">Robert C. Martin</a>, who is known for promoting design principles. Martin argues that side effects can result in <a href="/wiki/Sequential_coupling" title="Sequential coupling">temporal coupling</a> or order dependencies.<sup id="cite_ref-clean_code_21-0" class="reference"><a href="#cite_note-clean_code-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup> </p><p>In strictly <a href="/wiki/Functional_programming" title="Functional programming">functional programming</a> languages such as <a href="/wiki/Haskell_(programming_language)" class="mw-redirect" title="Haskell (programming language)">Haskell</a>, a function can have no <a href="/wiki/Side_effect_(computer_science)" title="Side effect (computer science)">side effects</a>, which means it cannot change the state of the program. Functions always return the same result for the same input. Such languages typically only support functions that return a value, since there is no value in a function that has neither return value nor side effect. </p><p><span class="anchor" id="LVRR"></span> </p> <div class="mw-heading mw-heading3"><h3 id="Local_variables">Local variables</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=17" title="Edit section: Local variables"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most contexts support <i>local variables</i> – <a href="/wiki/Virtual_memory" title="Virtual memory">memory</a> owned by a callable to hold intermediate values. These variables are typically stored in the call's <i>activation record</i> on the <a href="/wiki/Call_stack" title="Call stack">call stack</a> along with other information such as the <a href="/wiki/Return_address_(computing)" class="mw-redirect" title="Return address (computing)">return address</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Nested_call_–_recursion"><span id="Nested_call_.E2.80.93_recursion"></span>Nested call – recursion</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=18" title="Edit section: Nested call – recursion"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If supported by the language, a callable may call itself, causing its execution to suspend while another <i>nested</i> execution of the same callable executes. <a href="/wiki/Recursion" title="Recursion">Recursion</a> is a useful means to simplify some complex algorithms and break down complex problems. Recursive languages provide a new copy of local variables on each call. If the programmer desires the recursive callable to use the same variables instead of using locals, they typically declare them in a shared context such static or global. </p><p>Languages going back to <a href="/wiki/ALGOL" title="ALGOL">ALGOL</a>, <a href="/wiki/PL/I" title="PL/I">PL/I</a> and <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> and modern languages, almost invariably use a call stack, usually supported by the instruction sets to provide an activation record for each call. That way, a nested call can modify its local variables without affecting any of the suspended calls variables. </p><p>Recursion allows direct implementation of functionality defined by <a href="/wiki/Mathematical_induction" title="Mathematical induction">mathematical induction</a> and recursive <a href="/wiki/Divide_and_conquer_algorithm" class="mw-redirect" title="Divide and conquer algorithm">divide and conquer algorithms</a>. Here is an example of a recursive function in C/C++ to find <a href="/wiki/Fibonacci" title="Fibonacci">Fibonacci</a> numbers: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">int</span><span class="w"> </span><span class="nf">Fib</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </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">n</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">n</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">Fib</span><span class="p">(</span><span class="n">n</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Fib</span><span class="p">(</span><span class="n">n</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">2</span><span class="p">);</span> <span class="p">}</span> </pre></div> <p>Early languages like <a href="/wiki/Fortran" title="Fortran">Fortran</a> did not initially support recursion because only one set of variables and return address were allocated for each callable.<sup id="cite_ref-BöckenhauerKommUnger2018_22-0" class="reference"><a href="#cite_note-BöckenhauerKommUnger2018-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup> Early computer instruction sets made storing return addresses and variables on a stack difficult. Machines with <a href="/wiki/Index_registers" class="mw-redirect" title="Index registers">index registers</a> or <a href="/wiki/General-purpose_registers" class="mw-redirect" title="General-purpose registers">general-purpose registers</a>, e.g., <a href="/wiki/CDC_6000_series" title="CDC 6000 series">CDC 6000 series</a>, <a href="/wiki/PDP-6" title="PDP-6">PDP-6</a>, <a href="/wiki/GE_635" class="mw-redirect" title="GE 635">GE 635</a>, <a href="/wiki/System/360" class="mw-redirect" title="System/360">System/360</a>, <a href="/wiki/UNIVAC_1100_series" class="mw-redirect" title="UNIVAC 1100 series">UNIVAC 1100 series</a>, could use one of those registers as a <a href="/wiki/Stack_pointer" class="mw-redirect" title="Stack pointer">stack pointer</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Nested_scope">Nested scope</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=19" title="Edit section: Nested scope"><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/Nested_function" title="Nested function">Nested function</a></div> <p>Some languages, e.g., <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>, <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>, <a href="/wiki/PL/I" title="PL/I">PL/I</a>, <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, support declaring and defining a function inside, e.g., a function body, such that the name of the inner is only visible within the body of the outer. </p> <div class="mw-heading mw-heading3"><h3 id="Reentrancy">Reentrancy</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=20" title="Edit section: Reentrancy"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If a callable can be executed properly even when another execution of the same callable is already in progress, that callable is said to be <i><a href="/wiki/Reentrant_(subroutine)" class="mw-redirect" title="Reentrant (subroutine)">reentrant</a></i>. A reentrant callable is also useful in <a href="/wiki/Thread_(computer_science)" class="mw-redirect" title="Thread (computer science)">multi-threaded</a> situations since multiple threads can call the same callable without fear of interfering with each other. In the <a href="/wiki/IBM" title="IBM">IBM</a> <a href="/wiki/CICS" title="CICS">CICS</a> <a href="/wiki/Transaction_processing_system" title="Transaction processing system">transaction processing system</a>, <i>quasi-reentrant</i> was a slightly less restrictive, but similar, requirement for application programs that were shared by many threads. </p> <div class="mw-heading mw-heading3"><h3 id="Overloading">Overloading</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=21" title="Edit section: Overloading"><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/Function_overloading" title="Function overloading">Function overloading</a></div> <p>Some languages support <i>overloading</i> – allow multiple callables with the same name in the same scope, but operating on different types of input. Consider the square root function applied to real number, complex number and matrix input. The algorithm for each type of input is different, and the return value may have a different type. By writing three separate callables with the same name. i.e. <i>sqrt</i>, the resulting code may be easier to write and to maintain since each one has a name that is relatively easy to understand and to remember instead of giving longer and more complicated names like <i>sqrt_real</i>, <i>sqrt_complex</i>, <i>qrt_matrix</i>. </p><p>Overloading is supported in many languages that support <a href="/wiki/Strong_typing" class="mw-redirect" title="Strong typing">strong typing</a>. Often the compiler selects the overload to call based on the type of the input arguments or it fails if the input arguments do not select an overload. Older and weakly-typed languages generally do not support overloading. </p><p>Here is an example of overloading in <a href="/wiki/C%2B%2B" title="C++">C++</a>, two functions <code>Area</code> that accept different types: </p> <div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">// returns the area of a rectangle defined by height and width</span> <span class="kt">double</span><span class="w"> </span><span class="nf">Area</span><span class="p">(</span><span class="kt">double</span><span class="w"> </span><span class="n">h</span><span class="p">,</span><span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="n">w</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">h</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">w</span><span class="p">;</span><span class="w"> </span><span class="p">}</span> <span class="c1">// returns the area of a circle defined by radius</span> <span class="kt">double</span><span class="w"> </span><span class="nf">Area</span><span class="p">(</span><span class="kt">double</span><span class="w"> </span><span class="n">r</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3.14</span><span class="p">;</span><span class="w"> </span><span class="p">}</span> <span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="n">rectangle_area</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Area</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">);</span> <span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="n">circle_area</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Area</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span> <span class="p">}</span> </pre></div> <p>PL/I has the <code>GENERIC</code> attribute to define a generic name for a set of entry references called with different types of arguments. Example: </p> <pre>DECLARE gen_name GENERIC( name WHEN(FIXED BINARY), flame WHEN(FLOAT), pathname OTHERWISE);</pre> <p>Multiple argument definitions may be specified for each entry. A call to "gen_name" will result in a call to "name" when the argument is FIXED BINARY, "flame" when FLOAT", etc. If the argument matches none of the choices "pathname" will be called. </p> <div class="mw-heading mw-heading3"><h3 id="Closure">Closure</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=22" title="Edit section: Closure"><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/Closure_(computer_science)" class="mw-redirect" title="Closure (computer science)">Closure (computer science)</a></div> <p>A <i><a href="/wiki/Closure_(computer_science)" class="mw-redirect" title="Closure (computer science)">closure</a></i> is a callable plus values of some of its variables captured from the environment in which it was created. Closures were a notable feature of the Lisp programming language, introduced by <a href="/wiki/John_McCarthy_(computer_scientist)" title="John McCarthy (computer scientist)">John McCarthy</a>. Depending on the implementation, closures can serve as a mechanism for side-effects. </p> <div class="mw-heading mw-heading3"><h3 id="Exception_reporting">Exception reporting</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=23" title="Edit section: Exception reporting"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Besides its <a href="/wiki/Happy_path" title="Happy path">happy path</a> behavior, a callable may need to inform the caller about an <a href="/wiki/Exception_(computer_science)" class="mw-redirect" title="Exception (computer science)">exceptional</a> condition that occurred during its execution. </p><p>Most modern languages support exceptions which allows for exceptional control flow that pops the call stack until an exception handler is found to handle the condition. </p><p>Languages that do not support exceptions can use the return value to indicate success or failure of a call. Another approach is to use a well-known location like a global variable for success indication. A callable writes the value and the caller reads it after a call. </p><p>In the <a href="/wiki/IBM_System/360" title="IBM System/360">IBM System/360</a>, where return code was expected from a subroutine, the return value was often designed to be a multiple of 4—so that it could be used as a direct <a href="/wiki/Branch_table" title="Branch table">branch table</a> index into a branch table often located immediately after the call instruction to avoid extra conditional tests, further improving efficiency. In the <a href="/wiki/System/360" class="mw-redirect" title="System/360">System/360</a> <a href="/wiki/Assembly_language" title="Assembly language">assembly language</a>, one would write, for example: </p> <div class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr"><pre><span></span> BAL 14, SUBRTN01 go to a subroutine, storing return address in R14 B TABLE(15) use returned value in reg 15 to index the branch table, * branching to the appropriate branch instr. TABLE B OK return code =00 GOOD } B BAD return code =04 Invalid input } Branch table B ERROR return code =08 Unexpected condition } </pre></div> <div class="mw-heading mw-heading3"><h3 id="Call_overhead">Call overhead</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=24" title="Edit section: Call overhead"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A call has runtime <a href="/wiki/Computational_overhead" class="mw-redirect" title="Computational overhead">overhead</a>, which may include but is not limited to: </p> <ul><li>Allocating and reclaiming call stack storage</li> <li>Saving and restoring processor registers</li> <li>Copying input variables</li> <li>Copying values after the call into the caller's context</li> <li>Automatic testing of the return code</li> <li>Handling of exceptions</li> <li>Dispatching such as for a virtual method in an object-oriented language</li></ul> <p>Various techniques are employed to minimize the runtime cost of calls. </p> <div class="mw-heading mw-heading4"><h4 id="Compiler_optimization">Compiler optimization</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=25" title="Edit section: Compiler optimization"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some optimizations for minimizing call overhead may seem straight forward, but cannot be used if the callable has side effects. For example, in the expression <code>(f(x)-1)/(f(x)+1)</code>, the function <code>f</code> cannot be called only once with its value used two times since the two calls may return different results. Moreover, in the few languages which define the order of evaluation of the division operator's operands, the value of <code>x</code> must be fetched again before the second call, since the first call may have changed it. Determining whether a callable has a side effect is difficult – indeed, <a href="/wiki/Undecidable_problem" title="Undecidable problem">undecidable</a> by virtue of <a href="/wiki/Rice%27s_theorem" title="Rice's theorem">Rice's theorem</a>. So, while this optimization is safe in a purely functional programming language, a compiler for an language not limited to functional typically assumes the worst case, that every callable may have side effects. </p> <div class="mw-heading mw-heading4"><h4 id="Inlining">Inlining</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=26" title="Edit section: Inlining"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Inline_expansion" title="Inline expansion">Inlining</a> eliminates calls for particular callables. The compiler replaces each call with the compiled code of the callable. Not only does this avoid the call overhead, but it also allows the <a href="/wiki/Compiler" title="Compiler">compiler</a> to <a href="/wiki/Code_optimization" class="mw-redirect" title="Code optimization">optimize</a> code of the caller more effectively by taking into account the context and arguments at that call. Inlining, however, usually increases the compiled code size, except when only called once or the body is very short, like one line. </p> <div class="mw-heading mw-heading3"><h3 id="Sharing">Sharing</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=27" title="Edit section: Sharing"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Callables can be defined within a program, or separately in a <a href="/wiki/Library_(computing)" title="Library (computing)">library</a> that can be used by multiple programs. </p> <div class="mw-heading mw-heading3"><h3 id="Inter-operability">Inter-operability</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=28" title="Edit section: Inter-operability"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A <a href="/wiki/Compiler" title="Compiler">compiler</a> translates call and return statements into machine instructions according to a well-defined <a href="/wiki/Calling_convention" title="Calling convention">calling convention</a>. For code compiled by the same or a compatible compiler, functions can be compiled separately from the programs that call them. The instruction sequences corresponding to call and return statements are called the procedure's <a href="/wiki/Function_prologue" class="mw-redirect" title="Function prologue">prologue and epilogue</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Built-in_functions">Built-in functions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=29" title="Edit section: Built-in functions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><span class="anchor" id="Built-in_function"></span> </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951"><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Intrinsic_function" title="Intrinsic function">Intrinsic function</a></div> <p>A <i>built-in function</i>, or <i>builtin function</i>, or <i>intrinsic function</i>, is a function for which the compiler generates code at <a href="/wiki/Compile_time" title="Compile time">compile time</a> or provides in a way other than for other functions.<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup> A built-in function does not need to be defined like other functions since it is <i>built in</i> to the programming language.<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Programming">Programming</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=30" title="Edit section: Programming"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Trade-offs">Trade-offs</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=31" title="Edit section: Trade-offs"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading4"><h4 id="Advantages">Advantages</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=32" title="Edit section: Advantages"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Advantages of breaking a program into functions include: </p> <ul><li><a href="/wiki/Decomposition_(computer_science)" title="Decomposition (computer science)">Decomposing</a> a complex programming task into simpler steps: this is one of the two main tools of <a href="/wiki/Structured_programming" title="Structured programming">structured programming</a>, along with <a href="/wiki/Data_structure" title="Data structure">data structures</a></li> <li>Reducing <a href="/wiki/Duplicate_code" title="Duplicate code">duplicate code</a> within a program</li> <li>Enabling <a href="/wiki/Code_reuse" title="Code reuse">reuse of code</a> across multiple programs</li> <li>Dividing a large programming task among various programmers or various stages of a project</li> <li><a href="/wiki/Information_hiding" title="Information hiding">Hiding implementation details</a> from users of the function</li> <li>Improving readability of code by replacing a block of code with a function call where a <a rel="nofollow" class="external text" href="https://books.google.com/books?id=_i6bDeoCQzsC&pg=PA39&dq=descriptive+function+name">descriptive</a> function name serves to describe the block of code. This makes the calling code concise and readable even if the function is not meant to be reused.</li> <li>Improving <a href="/wiki/Traceability#Software" title="Traceability">traceability</a> (i.e. most languages offer ways to obtain the call trace which includes the names of the involved functions and perhaps even more information such as file names and line numbers); by not decomposing the code into functions, debugging would be severely impaired</li></ul> <div class="mw-heading mw-heading4"><h4 id="Disadvantages">Disadvantages</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=33" title="Edit section: Disadvantages"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Compared to using in-line code, invoking a function imposes some <a href="/wiki/Computational_overhead" class="mw-redirect" title="Computational overhead">computational overhead</a> in the call mechanism.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (February 2021)">citation needed</span></a></i>]</sup> </p><p>A function typically requires standard <a href="/wiki/Housekeeping_(computing)" title="Housekeeping (computing)">housekeeping</a> code – both at the entry to, and exit from, the function (<a href="/wiki/Function_prologue" class="mw-redirect" title="Function prologue">function prologue and epilogue</a> – usually saving <a href="/wiki/General_purpose_register" class="mw-redirect" title="General purpose register">general purpose registers</a> and return address as a minimum). </p> <div class="mw-heading mw-heading3"><h3 id="Conventions">Conventions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=34" title="Edit section: Conventions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Many programming conventions have been developed regarding callables. </p><p>With respect to naming, many developers name a callable with a phrase starting with a <a href="/wiki/Verb" title="Verb">verb</a> when it does a certain task, with an <a href="/wiki/Adjective" title="Adjective">adjective</a> when it makes an inquiry, and with a <a href="/wiki/Noun" title="Noun">noun</a> when it is used to substitute variables. </p><p>Some programmers suggest that a callable should perform exactly one task, and if it performs more than one task, it should be split up into multiple callables. They argue that callables are key components in <a href="/wiki/Software_maintenance" title="Software maintenance">software maintenance</a>, and their roles in the program must remain distinct. </p><p>Proponents of <a href="/wiki/Modular_programming" title="Modular programming">modular programming</a> advocate that each callable should have minimal dependency on the rest of the <a href="/wiki/Codebase" title="Codebase">codebase</a>. For example, the use of <a href="/wiki/Global_variable" title="Global variable">global variables</a> is generally deemed unwise, because it adds coupling between all callables that use the global variables. If such coupling is not necessary, they advise to <a href="/wiki/Code_refactoring" title="Code refactoring">refactor</a> callables to accept passed <a href="/wiki/Parameter_(computer_programming)" title="Parameter (computer programming)">parameters</a> instead. </p> <div class="mw-heading mw-heading2"><h2 id="Examples">Examples</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=35" title="Edit section: Examples"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Early_BASIC">Early BASIC</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=36" title="Edit section: Early BASIC"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Early BASIC variants require each line to have a unique number (<a href="/wiki/Line_number" title="Line number">line number</a>) that orders the lines for execution, provides no separation of the code that is callable, no mechanism for passing arguments or to return a value and all variables are global. It provides the command <code>GOSUB</code> where <i>sub</i> is short for <i>sub procedure</i>, <i>subprocedure</i> or <i>subroutine</i>. Control jumps to the specified line number and then continues on the next line on return. </p> <div class="mw-highlight mw-highlight-lang-basic mw-content-ltr" dir="ltr"><pre><span></span><span class="nl">10</span><span class="w"> </span><span class="c1">REM A BASIC PROGRAM</span> <span class="nl">20</span><span class="w"> </span><span class="kr">GOSUB</span><span class="w"> </span><span class="nl">100</span> <span class="nl">30</span><span class="w"> </span><span class="kr">GOTO</span><span class="w"> </span><span class="nl">20</span> <span class="nl">100</span><span class="w"> </span><span class="kr">INPUT</span><span class="w"> </span><span class="err">“</span><span class="vg">GIVE</span><span class="w"> </span><span class="vg">ME</span><span class="w"> </span><span class="vg">A</span><span class="w"> </span><span class="vg">NUMBER</span><span class="err">”</span><span class="p">;</span><span class="w"> </span><span class="vg">N</span> <span class="nl">110</span><span class="w"> </span><span class="kr">PRINT</span><span class="w"> </span><span class="err">“</span><span class="vg">THE</span><span class="w"> </span><span class="vg">SQUARE</span><span class="w"> </span><span class="vg">ROOT</span><span class="w"> </span><span class="vg">OF</span><span class="err">”</span><span class="p">;</span><span class="w"> </span><span class="vg">N</span><span class="p">;</span><span class="w"> </span> <span class="nl">120</span><span class="w"> </span><span class="kr">PRINT</span><span class="w"> </span><span class="err">“</span><span class="k">IS</span><span class="err">”</span><span class="p">;</span><span class="w"> </span><span class="vg">SQRT</span><span class="p">(</span><span class="vg">N</span><span class="p">)</span> <span class="nl">130</span><span class="w"> </span><span class="kr">RETURN</span> </pre></div> <p>This code repeatedly asks the user to enter a number and reports the square root of the value. Lines 100-130 are the callable. </p> <div class="mw-heading mw-heading3"><h3 id="Small_Basic">Small Basic</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=37" title="Edit section: Small Basic"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/Microsoft_Small_Basic" title="Microsoft Small Basic">Microsoft Small Basic</a>, targeted to the student first learning how to program in a text-based language, a callable unit is called a <i>subroutine</i>. The <code>Sub</code> keyword denotes the start of a subroutine and is followed by a name identifier. Subsequent lines are the body which ends with the <code>EndSub</code> keyword. <sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-vbnet mw-content-ltr" dir="ltr"><pre><span></span><span class="k">Sub</span><span class="w"> </span><span class="nf">SayHello</span> <span class="w"> </span><span class="n">TextWindow</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">"Hello!"</span><span class="p">)</span> <span class="n">EndSub</span> </pre></div> <p>This can be called as <code>SayHello()</code>. <sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Visual_Basic">Visual Basic</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=38" title="Edit section: Visual Basic"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In later versions of <a href="/wiki/Visual_Basic" title="Visual Basic">Visual Basic</a> (VB), including the <a href="/wiki/Visual_Basic_(.NET)" title="Visual Basic (.NET)">latest product line</a> and <a href="/wiki/Visual_Basic_(classic)" title="Visual Basic (classic)">VB6</a>, the term <i>procedure</i> is used for the callable unit concept. The keyword <code>Sub</code> is used to return no value and <code>Function</code> to return a value. When used in the context of a class, a procedure is a method. <sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup> </p><p>Each parameter has a <a href="/wiki/Data_type" title="Data type">data type</a> that can be specified, but if not, defaults to <code>Object</code> for later versions based on <a href="/wiki/.NET" title=".NET">.NET</a> and <a href="/wiki/Variant_type" class="mw-redirect" title="Variant type">variant</a> for <a href="/wiki/Visual_Basic_6" class="mw-redirect" title="Visual Basic 6">VB6</a>.<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup> </p><p>VB supports parameter passing conventions <a href="/wiki/Call_by_value" class="mw-redirect" title="Call by value">by value</a> and <a href="/wiki/Call_by_reference" class="mw-redirect" title="Call by reference">by reference</a> via the keywords <code>ByVal</code> and <code>ByRef</code>, respectively. Unless <code>ByRef</code> is specified, an argument is passed <code>ByVal</code>. Therefore, <code>ByVal</code> is rarely explicitly specified. </p><p>For a simple type like a number these conventions are relatively clear. Passing <code>ByRef</code> allows the procedure to modify the passed variable whereas passing <code>ByVal</code> does not. For an object, semantics can confuse programmers since an object is always treated as a reference. Passing an object <code>ByVal</code> copies the reference; not the state of the object. The called procedure can modify the state of the object via its methods yet cannot modify the object reference of the actual parameter. </p> <div class="mw-highlight mw-highlight-lang-vbnet mw-content-ltr" dir="ltr"><pre><span></span><span class="k">Sub</span><span class="w"> </span><span class="nf">DoSomething</span><span class="p">()</span> <span class="w"> </span><span class="c">' Some Code Here</span> <span class="k">End</span><span class="w"> </span><span class="k">Sub</span> </pre></div> <p>The does not return a value and has to be called stand-alone, like <code>DoSomething</code> </p> <div class="mw-highlight mw-highlight-lang-vbnet mw-content-ltr" dir="ltr"><pre><span></span><span class="k">Function</span><span class="w"> </span><span class="nf">GiveMeFive</span><span class="p">()</span><span class="w"> </span><span class="ow">as</span><span class="w"> </span><span class="kt">Integer</span> <span class="w"> </span><span class="n">GiveMeFive</span><span class="o">=</span><span class="w"> </span><span class="mi">5</span> <span class="k">End</span><span class="w"> </span><span class="k">Function</span> </pre></div> <p>This returns the value 5, and a call can be part of an expression like <code>y = x + GiveMeFive()</code> </p> <div class="mw-highlight mw-highlight-lang-vbnet mw-content-ltr" dir="ltr"><pre><span></span><span class="k">Sub</span><span class="w"> </span><span class="nf">AddTwo</span><span class="p">(</span><span class="k">ByRef</span><span class="w"> </span><span class="n">intValue</span><span class="w"> </span><span class="ow">as</span><span class="w"> </span><span class="kt">Integer</span><span class="p">)</span> <span class="w"> </span><span class="n">intValue</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">intValue</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span> <span class="k">End</span><span class="w"> </span><span class="k">Sub</span> </pre></div> <p>This has a side-effect – modifies the variable passed by reference and could be called for variable <code>v</code> like <code>AddTwo(v)</code>. Giving v is 5 before the call, it will be 7 after. </p> <div class="mw-heading mw-heading3"><h3 id="C_and_C++"><span id="C_and_C.2B.2B"></span>C and C++</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=39" title="Edit section: C and C++"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> and <a href="/wiki/C%2B%2B" title="C++">C++</a>, a callable unit is called a <i>function</i>. A function definition starts with the name of the type of value that it returns or <code>void</code> to indicate that it does not return a value. This is followed by the function name, formal arguments in parentheses, and body lines in braces. </p><p>In <a href="/wiki/C%2B%2B" title="C++">C++</a>, a function declared in a <a href="/wiki/Class_(computer_programming)" title="Class (computer programming)">class</a> (as non-static) is called a <i>member function</i> or <i>method</i>. A function outside of a class can be called a <i>free function</i> to distinguish it from a member function. <sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">void</span><span class="w"> </span><span class="nf">doSomething</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="cm">/* some code */</span> <span class="p">}</span> </pre></div> <p>This function does not return a value and is always called stand-alone, like <code>doSomething()</code> </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">int</span><span class="w"> </span><span class="nf">giveMeFive</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">5</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p>This function returns the integer value 5. The call can be stand-alone or in an expression like <code>y = x + giveMeFive()</code> </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">void</span><span class="w"> </span><span class="nf">addTwo</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">pi</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="o">*</span><span class="n">pi</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p>This function has a side-effect – modifies the value passed by address to the input value plus 2. It could be called for variable <code>v</code> as <code>addTwo(&v)</code> where the ampersand (&) tells the compiler to pass the address of a variable. Giving v is 5 before the call, it will be 7 after. </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">void</span><span class="w"> </span><span class="nf">addTwo</span><span class="p">(</span><span class="kt">int</span><span class="o">&</span><span class="w"> </span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p>This function requires C++ – would not compile as C. It has the same behavior as the preceding example but passes the actual parameter by reference rather than passing its address. A call such as <code>addTwo(v)</code> does not include an ampersand since the compiler handles passing by reference without syntax in the call. </p> <div class="mw-heading mw-heading3"><h3 id="PL/I"><span id="PL.2FI"></span>PL/I</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=40" title="Edit section: PL/I"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/PL/I" title="PL/I">PL/I</a> a called procedure may be passed a <i><a href="/wiki/Data_descriptor" title="Data descriptor">descriptor</a></i> providing information about the argument, such as string lengths and array bounds. This allows the procedure to be more general and eliminates the need for the programmer to pass such information. By default PL/I passes arguments by reference. A (trivial) function to change the sign of each element of a two-dimensional array might look like: </p> <pre>change_sign: procedure(array); declare array(*,*) float; array = -array; end change_sign; </pre> <p>This could be called with various arrays as follows: </p> <pre>/* first array bounds from -5 to +10 and 3 to 9 */ declare array1 (-5:10, 3:9)float; /* second array bounds from 1 to 16 and 1 to 16 */ declare array2 (16,16) float; call change_sign(array1); call change_sign(array2); </pre> <div class="mw-heading mw-heading3"><h3 id="Python">Python</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=41" title="Edit section: Python"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, the keyword <code>def</code> denotes the start of a function definition. The statements of the function body follow as indented on subsequent lines and end at the line that is indented the same as the first line or end of file.<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="k">def</span> <span class="nf">format_greeting</span><span class="p">(</span><span class="n">name</span><span class="p">):</span> <span class="k">return</span> <span class="s2">"Welcome "</span> <span class="o">+</span> <span class="n">name</span> <span class="k">def</span> <span class="nf">greet_martin</span><span class="p">():</span> <span class="nb">print</span><span class="p">(</span><span class="n">format_greeting</span><span class="p">(</span><span class="s2">"Martin"</span><span class="p">))</span> </pre></div> <p>The first function returns greeting text that includes the name passed by the caller. The second function calls the first and is called like <code>greet_martin()</code> to write "Welcome Martin" to the console. </p> <div class="mw-heading mw-heading3"><h3 id="Prolog">Prolog</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Function_(computer_programming)&action=edit&section=42" title="Edit section: Prolog"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the procedural interpretation of <a href="/wiki/Logic_programming" title="Logic programming">logic programs</a>, logical implications behave as goal-reduction procedures. A <a href="/wiki/Rule-based_system" title="Rule-based system">rule</a> (or <a href="/wiki/Clause_(logic)" title="Clause (logic)">clause</a>) of the form: </p> <dl><dd><code>A :- B</code></dd></dl> <p>which has the logical reading: </p> <dl><dd><code>A if B</code></dd></dl> <p>behaves as a procedure that reduces goals that <a href="/wiki/Unification_(computer_science)" title="Unification (computer science)">unify</a> with <code>A</code> to subgoals that are instances of<code>B</code>. </p><p>Consider, for example, the Prolog program: </p> <div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span></span><span class="nf">mother_child</span><span class="p">(</span><span class="s s-Atom">elizabeth</span><span class="p">,</span> <span class="s s-Atom">charles</span><span class="p">).</span> <span class="nf">father_child</span><span class="p">(</span><span class="s s-Atom">charles</span><span class="p">,</span> <span class="s s-Atom">william</span><span class="p">).</span> <span class="nf">father_child</span><span class="p">(</span><span class="s s-Atom">charles</span><span class="p">,</span> <span class="s s-Atom">harry</span><span class="p">).</span> <span class="nf">parent_child</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">mother_child</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">).</span> <span class="nf">parent_child</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">father_child</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">).</span> </pre></div> <p>Notice that the motherhood function, <code class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><span class="nv">X</span> <span class="o">=</span> <span class="nf">mother</span><span class="p">(</span><span class="nv">Y</span><span class="p">)</span></code> is represented by a relation, as in a <a href="/wiki/Relational_database" title="Relational database">relational database</a>. However, <i>relations</i> in Prolog <i>function</i> as callable units. </p><p>For example, the procedure call <code class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><span class="s s-Atom">?-</span> <span class="nf">parent_child</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">charles</span><span class="p">)</span></code> produces the output <code class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><span class="nv">X</span> <span class="o">=</span> <span class="s s-Atom">elizabeth</span></code>. But the same procedure can be called with other input-output patterns. For example: </p> <div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span></span><span class="s s-Atom">?-</span> <span class="nf">parent_child</span><span class="p">(</span><span class="s s-Atom">elizabeth</span><span class="p">,</span> <span class="nv">Y</span><span class="p">).</span> <span class="nv">Y</span> <span class="o">=</span> <span class="s s-Atom">charles</span><span class="p">.</span> <span class="s s-Atom">?-</span> <span class="nf">parent_child</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">).</span> <span class="nv">X</span> <span class="o">=</span> <span class="s s-Atom">elizabeth</span><span class="p">,</span> <span class="nv">Y</span> <span class="o">=</span> <span class="s s-Atom">charles</span><span class="p">.</span> <span class="nv">X</span> <span class="o">=</span> <span class="s s-Atom">charles</span><span class="p">,</span> <span class="nv">Y</span> <span class="o">=</span> <span class="s s-Atom">harry</span><span class="p">.</span> <span class="nv">X</span> <span class="o">=</span> <span class="s s-Atom">charles</span><span class="p">,</span> <span class="nv">Y</span> <span class="o">=</span> <span class="s s-Atom">william</span><span class="p">.</span> <span class="s s-Atom">?-</span> <span class="nf">parent_child</span><span class="p">(</span><span class="s s-Atom">william</span><span class="p">,</span> <span class="s s-Atom">harry</span><span class="p">).</span> <span class="s s-Atom">no</span><span class="p">.</span> <span class="s s-Atom">?-</span> <span class="nf">parent_child</span><span class="p">(</span><span class="s s-Atom">elizabeth</span><span class="p">,</span> <span class="s s-Atom">charles</span><span class="p">).</span> <span class="s s-Atom">yes</span><span class="p">.</span> </pre></div> <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=Function_(computer_programming)&action=edit&section=43" title="Edit section: See also"><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"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/9/99/Wiktionary-logo-en-v2.svg/40px-Wiktionary-logo-en-v2.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/9/99/Wiktionary-logo-en-v2.svg/60px-Wiktionary-logo-en-v2.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/9/99/Wiktionary-logo-en-v2.svg/80px-Wiktionary-logo-en-v2.svg.png 2x" data-file-width="512" data-file-height="512" /></span></span></div> <div class="side-box-text plainlist">Look up <i><b><a href="https://en.wiktionary.org/wiki/subroutine" class="extiw" title="wiktionary:subroutine">subroutine </a></b></i> or <i><b><a href="https://en.wiktionary.org/wiki/function" class="extiw" title="wiktionary:function"> function</a></b></i> in Wiktionary, the free dictionary.</div></div> </div> <ul><li><a href="/wiki/Asynchronous_procedure_call" title="Asynchronous procedure call">Asynchronous procedure call</a>, a subprogram that is called after its parameters are set by other activities</li> <li><a href="/wiki/Command%E2%80%93query_separation" title="Command–query separation">Command–query separation</a> (CQS)</li> <li><a href="/wiki/Compound_operation_(computer_programming)" class="mw-redirect" title="Compound operation (computer programming)">Compound operation</a></li> <li><a href="/wiki/Coroutine" title="Coroutine">Coroutines</a>, subprograms that call each other as if both were the main programs</li> <li><a href="/wiki/Evaluation_strategy" title="Evaluation strategy">Evaluation strategy</a></li> <li><a href="/wiki/Event_handler" class="mw-redirect" title="Event handler">Event handler</a>, a subprogram that is called in response to an input event or <a href="/wiki/Interrupt" title="Interrupt">interrupt</a></li> <li><a href="/wiki/Function_(mathematics)" title="Function (mathematics)">Function (mathematics)</a></li> <li><a href="/wiki/Functional_programming" title="Functional programming">Functional programming</a></li> <li><a href="/wiki/Fused_operation" class="mw-redirect" title="Fused operation">Fused operation</a></li> <li><a href="/wiki/Intrinsic_function" title="Intrinsic function">Intrinsic function</a></li> <li><a href="/wiki/Lambda_function_(computer_programming)" class="mw-redirect" title="Lambda function (computer programming)">Lambda function (computer programming)</a>, a function that is not bound to an identifier</li> <li><a href="/wiki/Logic_programming" title="Logic programming">Logic programming</a></li> <li><a href="/wiki/Modular_programming" title="Modular programming">Modular programming</a></li> <li><a href="/wiki/Operator_overloading" title="Operator overloading">Operator overloading</a></li> <li><a href="/wiki/Protected_procedure" title="Protected procedure">Protected procedure</a></li> <li><a href="/wiki/Transclusion" title="Transclusion">Transclusion</a></li></ul> <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=Function_(computer_programming)&action=edit&section=44" title="Edit section: References"><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"> <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"><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 class="citation web cs1"><a rel="nofollow" class="external text" href="https://pages.nist.gov/ElectionGlossary/">"Terminology Glossary"</a>. <i>nist.gov</i>. NIST<span class="reference-accessdate">. Retrieved <span class="nowrap">9 February</span> 2024</span>. <q>Callable unit: (Of a software program or logical design) Function, method, operation, subroutine, procedure, or analogous structural unit that appears within a module.</q></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=nist.gov&rft.atitle=Terminology+Glossary&rft_id=https%3A%2F%2Fpages.nist.gov%2FElectionGlossary%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-knuth1-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-knuth1_2-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFDonald_E._Knuth1997" class="citation book cs1"><a href="/wiki/Donald_Knuth" title="Donald Knuth">Donald E. Knuth</a> (1997). <i>The Art of Computer Programming, Volume I: Fundamental Algorithms</i>. Addison-Wesley. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-201-89683-4" title="Special:BookSources/0-201-89683-4"><bdi>0-201-89683-4</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=The+Art+of+Computer+Programming%2C+Volume+I%3A+Fundamental+Algorithms&rft.pub=Addison-Wesley&rft.date=1997&rft.isbn=0-201-89683-4&rft.au=Donald+E.+Knuth&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-structprog-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-structprog_3-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFO.-J._DahlE._W._DijkstraC._A._R._Hoare1972" class="citation book cs1">O.-J. Dahl; E. W. Dijkstra; C. A. R. Hoare (1972). <i>Structured Programming</i>. Academic Press. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-12-200550-3" title="Special:BookSources/0-12-200550-3"><bdi>0-12-200550-3</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Structured+Programming&rft.pub=Academic+Press&rft.date=1972&rft.isbn=0-12-200550-3&rft.au=O.-J.+Dahl&rft.au=E.+W.+Dijkstra&rft.au=C.+A.+R.+Hoare&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-mauchly0-4"><span class="mw-cite-backlink">^ <a href="#cite_ref-mauchly0_4-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-mauchly0_4-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="CITEREFMauchly1982" class="citation book cs1"><a href="/wiki/John_Mauchly" title="John Mauchly">Mauchly, J.W.</a> (1982). "Preparation of Problems for EDVAC-Type Machines". In Randell, Brian (ed.). <i>The Origins of Digital Computers</i>. Springer. pp. 393–397. <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-642-61812-3_31">10.1007/978-3-642-61812-3_31</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-3-642-61814-7" title="Special:BookSources/978-3-642-61814-7"><bdi>978-3-642-61814-7</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=Preparation+of+Problems+for+EDVAC-Type+Machines&rft.btitle=The+Origins+of+Digital+Computers&rft.pages=393-397&rft.pub=Springer&rft.date=1982&rft_id=info%3Adoi%2F10.1007%2F978-3-642-61812-3_31&rft.isbn=978-3-642-61814-7&rft.aulast=Mauchly&rft.aufirst=J.W.&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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 id="CITEREFWheeler1952" class="citation conference cs1"><a href="/wiki/David_Wheeler_(computer_scientist)" title="David Wheeler (computer scientist)">Wheeler, D. J.</a> (1952). <a rel="nofollow" class="external text" href="http://www.laputan.org/pub/papers/wheeler.pdf">"The use of sub-routines in programmes"</a> <span class="cs1-format">(PDF)</span>. <i>Proceedings of the 1952 ACM national meeting (Pittsburgh) on - ACM '52</i>. p. 235. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F609784.609816">10.1145/609784.609816</a></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=conference&rft.atitle=The+use+of+sub-routines+in+programmes&rft.btitle=Proceedings+of+the+1952+ACM+national+meeting+%28Pittsburgh%29+on+-+ACM+%2752&rft.pages=235&rft.date=1952&rft_id=info%3Adoi%2F10.1145%2F609784.609816&rft.aulast=Wheeler&rft.aufirst=D.+J.&rft_id=http%3A%2F%2Fwww.laputan.org%2Fpub%2Fpapers%2Fwheeler.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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 id="CITEREFWilkesWheelerGill1951" class="citation book cs1">Wilkes, M. V.; Wheeler, D. J.; Gill, S. (1951). <i>Preparation of Programs for an Electronic Digital Computer</i>. Addison-Wesley.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Preparation+of+Programs+for+an+Electronic+Digital+Computer&rft.pub=Addison-Wesley&rft.date=1951&rft.aulast=Wilkes&rft.aufirst=M.+V.&rft.au=Wheeler%2C+D.+J.&rft.au=Gill%2C+S.&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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="CITEREFDainith2004" class="citation encyclopaedia cs1">Dainith, John (2004). <a rel="nofollow" class="external text" href="http://www.encyclopedia.com/doc/1O11-opensubroutine.html">"<span class="cs1-kern-left"></span>"open subroutine." A Dictionary of Computing"</a>. <i>Encyclopedia.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">14 January</span> 2013</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=%22open+subroutine.%22+A+Dictionary+of+Computing&rft.btitle=Encyclopedia.com&rft.date=2004&rft.aulast=Dainith&rft.aufirst=John&rft_id=http%3A%2F%2Fwww.encyclopedia.com%2Fdoc%2F1O11-opensubroutine.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFTuring1945" class="citation cs2"><a href="/wiki/Alan_Turing" title="Alan Turing">Turing, Alan M.</a> (1945), <i>Report by Dr. A.M. Turing on proposals for the development of an Automatic Computing Engine (ACE): Submitted to the Executive Committee of the NPL in February 1946</i></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Report+by+Dr.+A.M.+Turing+on+proposals+for+the+development+of+an+Automatic+Computing+Engine+%28ACE%29%3A+Submitted+to+the+Executive+Committee+of+the+NPL+in+February+1946&rft.date=1945&rft.aulast=Turing&rft.aufirst=Alan+M.&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span> reprinted in <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFCopeland2005" class="citation book cs1"><a href="/wiki/Jack_Copeland" title="Jack Copeland">Copeland, B. J.</a>, ed. (2005). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/alanturingsautom0000unse"><i>Alan Turing's Automatic Computing Engine</i></a></span>. Oxford: Oxford University Press. p. 383. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-19-856593-3" title="Special:BookSources/0-19-856593-3"><bdi>0-19-856593-3</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Alan+Turing%27s+Automatic+Computing+Engine&rft.place=Oxford&rft.pages=383&rft.pub=Oxford+University+Press&rft.date=2005&rft.isbn=0-19-856593-3&rft_id=https%3A%2F%2Farchive.org%2Fdetails%2Falanturingsautom0000unse&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-Turing_1945-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-Turing_1945_9-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFTuring1946" class="citation cs2"><a href="/wiki/Alan_Mathison_Turing" class="mw-redirect" title="Alan Mathison Turing">Turing, Alan Mathison</a> (19 March 1946) [1945], <i>Proposals for Development in the Mathematics Division of an Automatic Computing Engine (ACE)</i></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Proposals+for+Development+in+the+Mathematics+Division+of+an+Automatic+Computing+Engine+%28ACE%29&rft.date=1946-03-19&rft.aulast=Turing&rft.aufirst=Alan+Mathison&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span> (NB. Presented on 1946-03-19 before the Executive Committee of the National Physical Laboratory (Great Britain).)</span> </li> <li id="cite_note-Carpenter_1977-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-Carpenter_1977_10-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFCarpenterDoran1977" class="citation journal cs1"><a href="/wiki/Brian_Carpenter_(Internet_engineer)" class="mw-redirect" title="Brian Carpenter (Internet engineer)">Carpenter, Brian Edward</a>; <a href="/wiki/Robert_William_Doran" class="mw-redirect" title="Robert William Doran">Doran, Robert William</a> (1 January 1977) [October 1975]. <a rel="nofollow" class="external text" href="https://doi.org/10.1093%2Fcomjnl%2F20.3.269">"The other Turing machine"</a>. <i><a href="/wiki/The_Computer_Journal" title="The Computer Journal">The Computer Journal</a></i>. <b>20</b> (3): 269–279. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1093%2Fcomjnl%2F20.3.269">10.1093/comjnl/20.3.269</a></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=The+Computer+Journal&rft.atitle=The+other+Turing+machine&rft.volume=20&rft.issue=3&rft.pages=269-279&rft.date=1977-01-01&rft_id=info%3Adoi%2F10.1093%2Fcomjnl%2F20.3.269&rft.aulast=Carpenter&rft.aufirst=Brian+Edward&rft.au=Doran%2C+Robert+William&rft_id=https%3A%2F%2Fdoi.org%2F10.1093%252Fcomjnl%252F20.3.269&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span> (11 pages)</span> </li> <li id="cite_note-:0-11"><span class="mw-cite-backlink">^ <a href="#cite_ref-:0_11-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-:0_11-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="CITEREFIsaacson2014" class="citation web cs1">Isaacson, Walter (18 September 2014). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20181212003245/http://fortune.com/2014/09/18/walter-isaacson-the-women-of-eniac/">"Walter Isaacson on the Women of ENIAC"</a>. <i>Fortune</i>. Archived from <a rel="nofollow" class="external text" href="http://fortune.com/2014/09/18/walter-isaacson-the-women-of-eniac/">the original</a> on 12 December 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">14 December</span> 2018</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Fortune&rft.atitle=Walter+Isaacson+on+the+Women+of+ENIAC&rft.date=2014-09-18&rft.aulast=Isaacson&rft.aufirst=Walter&rft_id=http%3A%2F%2Ffortune.com%2F2014%2F09%2F18%2Fwalter-isaacson-the-women-of-eniac%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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 id="CITEREFHerman_H._GoldstineJohn_von_Neumann1947" class="citation techreport cs1">Herman H. Goldstine; John von Neumann (1947). <a rel="nofollow" class="external text" href="https://www.ias.edu/sites/default/files/library/pdfs/ecp/planningcodingof0103inst.pdf">"Part II, Volume I-3, Planning and Coding of Problems for an Electronic Computing Instrument"</a> <span class="cs1-format">(PDF)</span>. <i>Report on the Mathematical and Logical aspects of an Electronic Computing Instrument</i> (Technical report).</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=report&rft.btitle=Report+on+the+Mathematical+and+Logical+aspects+of+an+Electronic+Computing+Instrument&rft.date=1947&rft.au=Herman+H.+Goldstine&rft.au=John+von+Neumann&rft_id=https%3A%2F%2Fwww.ias.edu%2Fsites%2Fdefault%2Ffiles%2Flibrary%2Fpdfs%2Fecp%2Fplanningcodingof0103inst.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span> (see p. 163 of the pdf for the relevant page)</span> </li> <li id="cite_note-B5000-21005-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-B5000-21005_13-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1"><a rel="nofollow" class="external text" href="http://bitsavers.org/pdf/burroughs/LargeSystems/B5000_5500_5700/5000-21005_B5000_operChar_1963.pdf"><i>The Operational Characteristics of the Processors for the Burroughs B5000</i></a> <span class="cs1-format">(PDF)</span>. Revision A. <a href="/wiki/Burroughs_Corporation" title="Burroughs Corporation">Burroughs Corporation</a>. 1963. 5000-21005<span class="reference-accessdate">. Retrieved <span class="nowrap">8 February</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=The+Operational+Characteristics+of+the+Processors+for+the+Burroughs+B5000&rft.series=Revision+A&rft.pub=Burroughs+Corporation&rft.date=1963&rft_id=http%3A%2F%2Fbitsavers.org%2Fpdf%2Fburroughs%2FLargeSystems%2FB5000_5500_5700%2F5000-21005_B5000_operChar_1963.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></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"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1"><a rel="nofollow" class="external text" href="http://bitsavers.org/pdf/dec/pdp6/F-65_PDP-6_Handbook_Aug64.pdf#page=35">"Push-Down Instructions"</a> <span class="cs1-format">(PDF)</span>. <a rel="nofollow" class="external text" href="http://bitsavers.org/pdf/dec/pdp6/F-65_PDP-6_Handbook_Aug64.pdf"><i>Programmed Data Processor 6 - Handbook</i></a> <span class="cs1-format">(PDF)</span>. p. 37<span class="reference-accessdate">. Retrieved <span class="nowrap">8 February</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=Push-Down+Instructions&rft.btitle=Programmed+Data+Processor+6+-+Handbook&rft.pages=37&rft_id=http%3A%2F%2Fbitsavers.org%2Fpdf%2Fdec%2Fpdp6%2FF-65_PDP-6_Handbook_Aug64.pdf%23page%3D35&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-Steele-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-Steele_15-0">^</a></b></span> <span class="reference-text"> <a href="/wiki/Guy_Lewis_Steele_Jr." class="mw-redirect" title="Guy Lewis Steele Jr.">Guy Lewis Steele Jr.</a> <a href="/wiki/AI_Memo" title="AI Memo">AI Memo</a> 443. <a rel="nofollow" class="external text" href="http://dspace.mit.edu/bitstream/handle/1721.1/5753/AIM-443.pdf?sequence=2">'Debunking the "Expensive Procedure Call" Myth; or, Procedure call implementations considered harmful"</a>. Section "C. Why Procedure Calls Have a Bad Reputation".</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"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFFrank1983" class="citation book cs1">Frank, Thomas S. (1983). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=YN4mAAAAMAAJ"><i>Introduction to the PDP-11 and Its Assembly Language</i></a>. Prentice-Hall software series. Prentice-Hall. p. 195. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/9780134917047" title="Special:BookSources/9780134917047"><bdi>9780134917047</bdi></a><span class="reference-accessdate">. Retrieved <span class="nowrap">6 July</span> 2016</span>. <q>We could supply our assembling clerk with copies of the source code for all of our useful subroutines and then when presenting him with a mainline program for assembly, tell him which subroutines will be called in the mainline [...]</q></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Introduction+to+the+PDP-11+and+Its+Assembly+Language&rft.series=Prentice-Hall+software+series&rft.pages=195&rft.pub=Prentice-Hall&rft.date=1983&rft.isbn=9780134917047&rft.aulast=Frank&rft.aufirst=Thomas+S.&rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DYN4mAAAAMAAJ&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-ButtlarFarrellNichols1996-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-ButtlarFarrellNichols1996_17-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFButtlarFarrellNichols1996" class="citation book cs1">Buttlar, Dick; Farrell, Jacqueline; Nichols, Bradford (1996). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=vjgEEAAAQBAJ&pg=PA2"><i>PThreads Programming: A POSIX Standard for Better Multiprocessing</i></a>. "O'Reilly Media, Inc.". pp. 2–5. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-1-4493-6475-5" title="Special:BookSources/978-1-4493-6475-5"><bdi>978-1-4493-6475-5</bdi></a>. <a href="/wiki/OCLC_(identifier)" class="mw-redirect" title="OCLC (identifier)">OCLC</a> <a rel="nofollow" class="external text" href="https://search.worldcat.org/oclc/1036778036">1036778036</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=PThreads+Programming%3A+A+POSIX+Standard+for+Better+Multiprocessing&rft.pages=2-5&rft.pub=%22O%27Reilly+Media%2C+Inc.%22&rft.date=1996&rft_id=info%3Aoclcnum%2F1036778036&rft.isbn=978-1-4493-6475-5&rft.aulast=Buttlar&rft.aufirst=Dick&rft.au=Farrell%2C+Jacqueline&rft.au=Nichols%2C+Bradford&rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DvjgEEAAAQBAJ%26pg%3DPA2&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</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://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka13785.html">"ARM Information Center"</a>. Infocenter.arm.com<span class="reference-accessdate">. Retrieved <span class="nowrap">29 September</span> 2013</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=ARM+Information+Center&rft.pub=Infocenter.arm.com&rft_id=http%3A%2F%2Finfocenter.arm.com%2Fhelp%2Findex.jsp%3Ftopic%3D%2Fcom.arm.doc.faqs%2Fka13785.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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"><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.microsoft.com/en-us/cpp/build/stack-usage">"x64 stack usage"</a>. <i>Microsoft Docs</i>. Microsoft<span class="reference-accessdate">. Retrieved <span class="nowrap">5 August</span> 2019</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Microsoft+Docs&rft.atitle=x64+stack+usage&rft_id=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcpp%2Fbuild%2Fstack-usage&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</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://msdn.microsoft.com/en-us/library/67fa79wz%28v=VS.90%29.aspx">"Function Types"</a>. Msdn.microsoft.com<span class="reference-accessdate">. Retrieved <span class="nowrap">29 September</span> 2013</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Function+Types&rft.pub=Msdn.microsoft.com&rft_id=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2F67fa79wz%2528v%3DVS.90%2529.aspx&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-clean_code-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-clean_code_21-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFMartin2008" class="citation book cs1">Martin, Robert C. (1 August 2008). <a rel="nofollow" class="external text" href="https://www.oreilly.com/library/view/clean-code-a/9780136083238/"><i>Clean Code: A Handbook of Agile Software Craftsmanship</i></a> (1 ed.). <a href="/wiki/Pearson_PLC" class="mw-redirect" title="Pearson PLC">Pearson</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/9780132350884" title="Special:BookSources/9780132350884"><bdi>9780132350884</bdi></a><span class="reference-accessdate">. Retrieved <span class="nowrap">19 May</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Clean+Code%3A+A+Handbook+of+Agile+Software+Craftsmanship&rft.edition=1&rft.pub=Pearson&rft.date=2008-08-01&rft.isbn=9780132350884&rft.aulast=Martin&rft.aufirst=Robert+C.&rft_id=https%3A%2F%2Fwww.oreilly.com%2Flibrary%2Fview%2Fclean-code-a%2F9780136083238%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> <li id="cite_note-BöckenhauerKommUnger2018-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-BöckenhauerKommUnger2018_22-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFVerhoeff2018" class="citation book cs1">Verhoeff, Tom (2018). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=Z_5sDwAAQBAJ&pg=PA616">"A Master Class on Recursion"</a>. In Böckenhauer, Hans-Joachim; Komm, Dennis; Unger, Walter (eds.). <i>Adventures Between Lower Bounds and Higher Altitudes: Essays Dedicated to Juraj Hromkovič on the Occasion of His 60th Birthday</i>. Springer. p. 616. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-3-319-98355-4" title="Special:BookSources/978-3-319-98355-4"><bdi>978-3-319-98355-4</bdi></a>. <a href="/wiki/OCLC_(identifier)" class="mw-redirect" title="OCLC (identifier)">OCLC</a> <a rel="nofollow" class="external text" href="https://search.worldcat.org/oclc/1050567095">1050567095</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=A+Master+Class+on+Recursion&rft.btitle=Adventures+Between+Lower+Bounds+and+Higher+Altitudes%3A+Essays+Dedicated+to+Juraj+Hromkovi%C4%8D+on+the+Occasion+of+His+60th+Birthday&rft.pages=616&rft.pub=Springer&rft.date=2018&rft_id=info%3Aoclcnum%2F1050567095&rft.isbn=978-3-319-98355-4&rft.aulast=Verhoeff&rft.aufirst=Tom&rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DZ_5sDwAAQBAJ%26pg%3DPA616&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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"><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.ibm.com/docs/en/zos/2.2.0?topic=lf-built-in-functions">"Built-in functions"</a>. <i>ibm.com</i>. 9 March 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">25 December</span> 2023</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=ibm.com&rft.atitle=Built-in+functions&rft.date=2017-03-09&rft_id=https%3A%2F%2Fwww.ibm.com%2Fdocs%2Fen%2Fzos%2F2.2.0%3Ftopic%3Dlf-built-in-functions&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></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"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1"><a rel="nofollow" class="external text" href="https://books.google.com/books?id=d0nhEAAAQBAJ&pg=PA87"><i>Study Material Python</i></a>. April 2023. p. 87<span class="reference-accessdate">. Retrieved <span class="nowrap">25 December</span> 2023</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Study+Material+Python&rft.pages=87&rft.date=2023-04&rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Dd0nhEAAAQBAJ%26pg%3DPA87&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></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 class="citation web cs1"><a rel="nofollow" class="external text" href="https://smallbasic-publicwebsite.azurewebsites.net/">"Small Basic"</a>. <i>Small Basic</i><span class="reference-accessdate">. Retrieved <span class="nowrap">8 February</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Small+Basic&rft.atitle=Small+Basic&rft_id=https%3A%2F%2Fsmallbasic-publicwebsite.azurewebsites.net%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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://social.technet.microsoft.com/wiki/contents/articles/16077.small-basic-getting-started-guide-chapter-9-subroutines.aspx">"Small Basic Getting Started Guide: Chapter 9: Subroutines"</a>. Microsoft. 17 January 2024.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Small+Basic+Getting+Started+Guide%3A+Chapter+9%3A+Subroutines&rft.pub=Microsoft&rft.date=2024-01-17&rft_id=https%3A%2F%2Fsocial.technet.microsoft.com%2Fwiki%2Fcontents%2Farticles%2F16077.small-basic-getting-started-guide-chapter-9-subroutines.aspx&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/">"Procedures in Visual Basic"</a>. <i>Microsoft Learn</i>. 15 September 2021<span class="reference-accessdate">. Retrieved <span class="nowrap">8 February</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Microsoft+Learn&rft.atitle=Procedures+in+Visual+Basic&rft.date=2021-09-15&rft_id=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fdotnet%2Fvisual-basic%2Fprogramming-guide%2Flanguage-features%2Fprocedures%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/dim-statement">"Dim statement (Visual Basic)"</a>. <i>Microsoft Learn</i>. 15 September 2021<span class="reference-accessdate">. Retrieved <span class="nowrap">8 February</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Microsoft+Learn&rft.atitle=Dim+statement+%28Visual+Basic%29&rft.date=2021-09-15&rft_id=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fdotnet%2Fvisual-basic%2Flanguage-reference%2Fstatements%2Fdim-statement&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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://stackoverflow.com/questions/4861914/what-is-the-meaning-of-the-term-free-function-in-c">"what is meant by a free function"</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=what+is+meant+by+a+free+function&rft_id=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F4861914%2Fwhat-is-the-meaning-of-the-term-free-function-in-c&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" 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://docs.python.org/3.9/tutorial/controlflow.html#defining-functions">"4. More Control Flow Tools — Python 3.9.7 documentation"</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=4.+More+Control+Flow+Tools+%E2%80%94+Python+3.9.7+documentation&rft_id=https%3A%2F%2Fdocs.python.org%2F3.9%2Ftutorial%2Fcontrolflow.html%23defining-functions&rfr_id=info%3Asid%2Fen.wikipedia.org%3AFunction+%28computer+programming%29" class="Z3988"></span></span> </li> </ol></div></div> <div class="navbox-styles"><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:r1236075235">.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}</style></div><div role="navigation" class="navbox authority-control" aria-label="Navbox" style="padding:3px"><table class="nowraplinks hlist navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Help:Authority_control" title="Help:Authority control">Authority control databases</a>: National <span class="mw-valign-text-top noprint" typeof="mw:File/Frameless"><a href="https://www.wikidata.org/wiki/Q190686#identifiers" title="Edit this at Wikidata"><img alt="Edit this at Wikidata" src="//upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png" decoding="async" width="10" height="10" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/15px-OOjs_UI_icon_edit-ltr-progressive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/20px-OOjs_UI_icon_edit-ltr-progressive.svg.png 2x" data-file-width="20" data-file-height="20" /></a></span></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://d-nb.info/gnd/4253859-2">Germany</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://id.loc.gov/authorities/sh85129527">United States</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="http://olduli.nli.org.il/F/?func=find-b&local_base=NLX10&find_code=UID&request=987007543737405171">Israel</a></span></li></ul></div></td></tr></tbody></table></div> <!-- NewPP limit report Parsed by mw‐web.codfw.main‐f69cdc8f6‐869cr Cached time: 20241122144848 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.582 seconds Real time usage: 0.898 seconds Preprocessor visited node count: 3510/1000000 Post‐expand include size: 71507/2097152 bytes Template argument size: 5555/2097152 bytes Highest expansion depth: 12/100 Expensive parser function count: 33/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 129706/5000000 bytes Lua time usage: 0.336/10.000 seconds Lua memory usage: 6707288/52428800 bytes Number of Wikibase entities loaded: 1/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 780.336 1 -total 30.78% 240.216 1 Template:Reflist 17.30% 134.963 2 Template:Code 15.00% 117.058 12 Template:Cite_web 10.48% 81.769 1 Template:Short_description 8.67% 67.686 1 Template:Authority_control 7.85% 61.218 12 Template:Cite_book 7.02% 54.799 5 Template:Citation_needed 6.07% 47.339 5 Template:Fix 6.01% 46.888 2 Template:Pagetype --> <!-- Saved in parser cache with key enwiki:pcache:idhash:32177451-0!canonical and timestamp 20241122144848 and revision id 1253066507. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" 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=Function_(computer_programming)&oldid=1253066507">https://en.wikipedia.org/w/index.php?title=Function_(computer_programming)&oldid=1253066507</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:Source_code" title="Category:Source code">Source code</a></li><li><a href="/wiki/Category:Holism" title="Category:Holism">Holism</a></li><li><a href="/wiki/Category:Programming_constructs" title="Category:Programming constructs">Programming constructs</a></li><li><a href="/wiki/Category:Subroutines" title="Category:Subroutines">Subroutines</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: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:Use_dmy_dates_from_April_2022" title="Category:Use dmy dates from April 2022">Use dmy dates from April 2022</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_November_2008" title="Category:Articles with unsourced statements from November 2008">Articles with unsourced statements from November 2008</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_unsourced_statements_from_June_2011" title="Category:Articles with unsourced statements from June 2011">Articles with unsourced statements from June 2011</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_February_2021" title="Category:Articles with unsourced statements from February 2021">Articles with unsourced statements from February 2021</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></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 24 October 2024, at 05:40<span class="anonymous-show"> (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=Function_(computer_programming)&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://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></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"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-f69cdc8f6-n58kz","wgBackendResponseTime":177,"wgPageParseReport":{"limitreport":{"cputime":"0.582","walltime":"0.898","ppvisitednodes":{"value":3510,"limit":1000000},"postexpandincludesize":{"value":71507,"limit":2097152},"templateargumentsize":{"value":5555,"limit":2097152},"expansiondepth":{"value":12,"limit":100},"expensivefunctioncount":{"value":33,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":129706,"limit":5000000},"entityaccesscount":{"value":1,"limit":400},"timingprofile":["100.00% 780.336 1 -total"," 30.78% 240.216 1 Template:Reflist"," 17.30% 134.963 2 Template:Code"," 15.00% 117.058 12 Template:Cite_web"," 10.48% 81.769 1 Template:Short_description"," 8.67% 67.686 1 Template:Authority_control"," 7.85% 61.218 12 Template:Cite_book"," 7.02% 54.799 5 Template:Citation_needed"," 6.07% 47.339 5 Template:Fix"," 6.01% 46.888 2 Template:Pagetype"]},"scribunto":{"limitreport-timeusage":{"value":"0.336","limit":"10.000"},"limitreport-memusage":{"value":6707288,"limit":52428800}},"cachereport":{"origin":"mw-web.codfw.main-f69cdc8f6-869cr","timestamp":"20241122144848","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Function (computer programming)","url":"https:\/\/en.wikipedia.org\/wiki\/Function_(computer_programming)","sameAs":"http:\/\/www.wikidata.org\/entity\/Q190686","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q190686","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":"2003-04-26T21:15:02Z","dateModified":"2024-10-24T05:40:25Z","headline":"sequence of instructions that can be called from other points in a computer program"}</script> </body> </html>