CINXE.COM
eval - 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>eval - 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":"b7ac8e07-0fde-4e40-9041-f7f0b36c1de5","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Eval","wgTitle":"Eval","wgCurRevisionId":1253996606,"wgRevisionId":1253996606,"wgArticleId":623831,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description is different from Wikidata","Control flow","Unix SUS2008 utilities","IBM i Qshell commands"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Eval","wgRelevantArticleId":623831,"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":20000,"wgRelatedArticlesCompat":[],"wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q940058","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.pygments":"ready","ext.cite.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.pygments.view","ext.cite.ux-enhancements","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","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns", "ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.quicksurveys.init","ext.growthExperiments.SuggestedEditSession","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="eval - Wikipedia"> <meta property="og:type" content="website"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/Eval"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Eval&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/Eval"> <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-Eval rootpage-Eval 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=Eval" 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=Eval" 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=Eval" 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=Eval" 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-Security_risks" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Security_risks"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Security risks</span> </div> </a> <ul id="toc-Security_risks-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Implementation" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Implementation"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Implementation</span> </div> </a> <ul id="toc-Implementation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Programming_languages" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Programming_languages"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Programming languages</span> </div> </a> <button aria-controls="toc-Programming_languages-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 languages subsection</span> </button> <ul id="toc-Programming_languages-sublist" class="vector-toc-list"> <li id="toc-ECMAScript" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#ECMAScript"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1</span> <span>ECMAScript</span> </div> </a> <ul id="toc-ECMAScript-sublist" class="vector-toc-list"> <li id="toc-JavaScript" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#JavaScript"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.1</span> <span>JavaScript</span> </div> </a> <ul id="toc-JavaScript-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-ActionScript" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#ActionScript"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1.2</span> <span>ActionScript</span> </div> </a> <ul id="toc-ActionScript-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Lisp" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Lisp"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2</span> <span>Lisp</span> </div> </a> <ul id="toc-Lisp-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Perl" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Perl"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.3</span> <span>Perl</span> </div> </a> <ul id="toc-Perl-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PHP" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PHP"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.4</span> <span>PHP</span> </div> </a> <ul id="toc-PHP-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Lua" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Lua"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.5</span> <span>Lua</span> </div> </a> <ul id="toc-Lua-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PostScript" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PostScript"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.6</span> <span>PostScript</span> </div> </a> <ul id="toc-PostScript-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">3.7</span> <span>Python</span> </div> </a> <ul id="toc-Python-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-D" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#D"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.8</span> <span>D</span> </div> </a> <ul id="toc-D-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-ColdFusion" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#ColdFusion"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.9</span> <span>ColdFusion</span> </div> </a> <ul id="toc-ColdFusion-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Ruby" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Ruby"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.10</span> <span>Ruby</span> </div> </a> <ul id="toc-Ruby-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Forth" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Forth"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.11</span> <span>Forth</span> </div> </a> <ul id="toc-Forth-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-BASIC" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#BASIC"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.12</span> <span>BASIC</span> </div> </a> <ul id="toc-BASIC-sublist" class="vector-toc-list"> <li id="toc-REALbasic" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#REALbasic"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.12.1</span> <span>REALbasic</span> </div> </a> <ul id="toc-REALbasic-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-VBScript" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#VBScript"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.12.2</span> <span>VBScript</span> </div> </a> <ul id="toc-VBScript-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Visual_Basic_for_Applications" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Visual_Basic_for_Applications"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.12.3</span> <span>Visual Basic for Applications</span> </div> </a> <ul id="toc-Visual_Basic_for_Applications-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Smalltalk" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Smalltalk"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.13</span> <span>Smalltalk</span> </div> </a> <ul id="toc-Smalltalk-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Tcl" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Tcl"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.14</span> <span>Tcl</span> </div> </a> <ul id="toc-Tcl-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-bs" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#bs"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.15</span> <span>bs</span> </div> </a> <ul id="toc-bs-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Command-line_interpreters" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Command-line_interpreters"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Command-line interpreters</span> </div> </a> <button aria-controls="toc-Command-line_interpreters-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 Command-line interpreters subsection</span> </button> <ul id="toc-Command-line_interpreters-sublist" class="vector-toc-list"> <li id="toc-Unix_shells" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Unix_shells"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>Unix shells</span> </div> </a> <ul id="toc-Unix_shells-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PowerShell" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PowerShell"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>PowerShell</span> </div> </a> <ul id="toc-PowerShell-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Microcode" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Microcode"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Microcode</span> </div> </a> <ul id="toc-Microcode-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Theory" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Theory"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Theory</span> </div> </a> <ul id="toc-Theory-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">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> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>External links</span> </div> </a> <ul id="toc-External_links-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <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">eval</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 8 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-8" 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">8 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Eval" title="Eval – German" lang="de" hreflang="de" data-title="Eval" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Eval" title="Eval – Spanish" lang="es" hreflang="es" data-title="Eval" 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-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Eval" title="Eval – French" lang="fr" hreflang="fr" data-title="Eval" 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/Eval" title="Eval – Korean" lang="ko" hreflang="ko" data-title="Eval" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-id mw-list-item"><a href="https://id.wikipedia.org/wiki/Eval" title="Eval – Indonesian" lang="id" hreflang="id" data-title="Eval" 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-ms mw-list-item"><a href="https://ms.wikipedia.org/wiki/Eval" title="Eval – Malay" lang="ms" hreflang="ms" data-title="Eval" data-language-autonym="Bahasa Melayu" data-language-local-name="Malay" class="interlanguage-link-target"><span>Bahasa Melayu</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/Eval" title="Eval – Japanese" lang="ja" hreflang="ja" data-title="Eval" data-language-autonym="日本語" data-language-local-name="Japanese" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/Eval" title="Eval – Chinese" lang="zh" hreflang="zh" data-title="Eval" 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/Q940058#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/Eval" 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:Eval" 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/Eval"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Eval&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=Eval&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/Eval"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Eval&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=Eval&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/Eval" 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/Eval" 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=Eval&oldid=1253996606" 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=Eval&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=Eval&id=1253996606&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%2FEval"><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%2FEval"><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=Eval&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=Eval&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 id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q940058" 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">Function in a programming language, which evaluates a string</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">"Evaluation (computer science)" redirects here. For other uses, see <a href="/wiki/Evaluation_(disambiguation)" class="mw-disambig" title="Evaluation (disambiguation)">Evaluation (disambiguation)</a>.</div> <p>In some <a href="/wiki/Programming_language" title="Programming language">programming languages</a>, <b><code>eval</code></b> , short for the English <a href="https://en.wiktionary.org/wiki/evaluate" class="extiw" title="wiktionary:evaluate">evaluate</a>, is a <a href="/wiki/Subroutine" class="mw-redirect" title="Subroutine">function</a> which evaluates a string as though it were an <a href="/wiki/Expression_(programming)" class="mw-redirect" title="Expression (programming)">expression</a> in the language, and returns a <a href="/wiki/Return_value" class="mw-redirect" title="Return value">result</a>; in others, it executes multiple lines of code as though they had been included instead of the line including the <code>eval</code>. The input to <code>eval</code> is not necessarily a string; it may be structured representation of code, such as an <a href="/wiki/Abstract_syntax_tree" title="Abstract syntax tree">abstract syntax tree</a> (like <a href="/wiki/Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a> forms), or of special type such as <code>code</code> (as in Python). The analog for a <a href="/wiki/Statement_(computer_science)" title="Statement (computer science)">statement</a> is <a href="/wiki/Exec_(system_call)" title="Exec (system call)">exec</a>, which executes a string (or code in other format) as if it were a statement; in some languages, such as Python, both are present, while in other languages only one of either <code>eval</code> or <code>exec</code> is. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Security_risks">Security risks</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=1" title="Edit section: Security risks"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Using <code>eval</code> with data from an untrusted source may introduce security vulnerabilities. For instance, assuming that the <code>get_data()</code> function gets data from the Internet, this <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a> code is insecure: </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">session</span><span class="p">[</span><span class="s1">'authenticated'</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> <span class="n">data</span> <span class="o">=</span> <span class="n">get_data</span><span class="p">()</span> <span class="n">foo</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> </pre></div> <p>An attacker <a href="/wiki/Code_injection" title="Code injection">could supply the program</a> with the string <code>"session.update(authenticated=True)"</code> as data, which would update the <code>session</code> dictionary to set an authenticated key to be True. To remedy this, all data which will be used with <code>eval</code> must be escaped, or it must be run without access to potentially harmful functions. </p> <div class="mw-heading mw-heading2"><h2 id="Implementation">Implementation</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=2" title="Edit section: Implementation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/Interpreted_language" class="mw-redirect" title="Interpreted language">interpreted languages</a>, <code>eval</code> is almost always implemented with the same interpreter as normal code. In <a href="/wiki/Compiled_language" title="Compiled language">compiled languages</a>, the same compiler used to compile programs may be embedded in programs using the <code>eval</code> function; separate interpreters are sometimes used, though this results in <a href="/wiki/Code_duplication" class="mw-redirect" title="Code duplication">code duplication</a>. </p> <div class="mw-heading mw-heading2"><h2 id="Programming_languages">Programming languages</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=3" title="Edit section: Programming languages"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="ECMAScript">ECMAScript</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=4" title="Edit section: ECMAScript"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading4"><h4 id="JavaScript">JavaScript</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=5" title="Edit section: JavaScript"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/JavaScript" title="JavaScript">JavaScript</a>, <code>eval</code> is something of a hybrid between an expression evaluator and a statement executor. It returns the result of the last expression evaluated. </p><p>Example as an expression evaluator: </p> <div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2</span><span class="p">;</span> <span class="nx">alert</span><span class="p">(</span><span class="nb">eval</span><span class="p">(</span><span class="s1">'foo + 2'</span><span class="p">));</span> </pre></div> <p>Example as a statement executor: </p> <div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2</span><span class="p">;</span> <span class="nb">eval</span><span class="p">(</span><span class="s1">'foo = foo + 2;alert(foo);'</span><span class="p">);</span> </pre></div> <p>One use of JavaScript's <code>eval</code> is to parse <a href="/wiki/JSON" title="JSON">JSON</a> text, perhaps as part of an <a href="/wiki/Ajax_(programming)" title="Ajax (programming)">Ajax</a> framework. However, modern browsers provide <code>JSON.parse</code> as a more secure alternative for this task. </p> <div class="mw-heading mw-heading4"><h4 id="ActionScript">ActionScript</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=6" title="Edit section: ActionScript"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/ActionScript" title="ActionScript">ActionScript</a> (Flash's programming language), <code>eval</code> cannot be used to evaluate arbitrary expressions. According to the Flash 8 documentation, its usage is limited to expressions which represent "the name of a variable, property, object, or movie clip to retrieve. This parameter can be either a String or a direct reference to the object instance."<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> </p><p>ActionScript 3 does not support eval. </p><p>The ActionScript 3 Eval Library<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> and the D.eval API<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> were development projects to create equivalents to <code>eval</code> in ActionScript 3. Both have ended, as <a href="/wiki/Adobe_Flash_Player" title="Adobe Flash Player">Adobe Flash Player</a> has reached its <a href="/wiki/End-of-life_product" title="End-of-life product">end-of-life</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Lisp">Lisp</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=7" title="Edit section: Lisp"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Lisp_programming_language" class="mw-redirect" title="Lisp programming language">Lisp</a> was the original language to make use of an <code>eval</code> function in 1958. In fact, definition of the <code>eval</code> function led to the first implementation of the language interpreter.<sup id="cite_ref-mccarthy_4-0" class="reference"><a href="#cite_note-mccarthy-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> Before the <code>eval</code> function was defined, Lisp functions were manually compiled to <a href="/wiki/Assembly_language" title="Assembly language">assembly language</a> statements. However, once the <code>eval</code> function had been manually compiled it was then used as part of a simple <a href="/wiki/Read-eval-print_loop" class="mw-redirect" title="Read-eval-print loop">read-eval-print loop</a> which formed the basis of the first Lisp interpreter. </p><p>Later versions of the Lisp <code>eval</code> function have also been implemented as compilers. </p><p>The <code>eval</code> function in Lisp expects a form to be evaluated as it's argument. The resulting value of the given form will be the returned value of the call to <code>eval</code>. </p><p>This is an example Lisp code: </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">; A form which calls the + function with 1,2 and 3 as arguments.</span> <span class="c1">; It returns 6.</span> <span class="p">(</span><span class="nb">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="mi">3</span><span class="p">)</span> <span class="c1">; In Lisp any form is meant to be evaluated, therefore</span> <span class="c1">; the call to + was performed.</span> <span class="c1">; We can prevent Lisp from performing evaluation</span> <span class="c1">; of a form by prefixing it with "'", for example:</span> <span class="p">(</span><span class="k">setq</span><span class="w"> </span><span class="nv">form1</span><span class="w"> </span><span class="o">'</span><span class="p">(</span><span class="nb">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="mi">3</span><span class="p">))</span> <span class="c1">; Now form1 contains a form that can be used by eval, for</span> <span class="c1">; example:</span> <span class="p">(</span><span class="nb">eval</span><span class="w"> </span><span class="nv">form1</span><span class="p">)</span> <span class="c1">; eval evaluated (+ 1 2 3) and returned 6.</span> </pre></div> <p>Lisp is well known to be very flexible and so is the <code>eval</code> function. For example, to evaluate the content of a string, the string would first have to be converted into a Lisp form using the <code>read-from-string</code> function and then the resulting form would have to be passed to <code>eval</code>: </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">eval</span><span class="w"> </span><span class="p">(</span><span class="nb">read-from-string</span><span class="w"> </span><span class="s">"(format t \"Hello World!!!~%\")"</span><span class="p">))</span> </pre></div> <p>One major point of confusion is the question, in which context the symbols in the form will be evaluated. In the above example, <code>form1</code> contains the symbol <code>+</code>. Evaluation of this symbol must yield the function for addition to make the example work as intended. Thus some dialects of Lisp allow an additional parameter for <code>eval</code> to specify the context of evaluation (similar to the optional arguments to Python's <code>eval</code> function - see below). An example in the <a href="/wiki/Scheme_(programming_language)" title="Scheme (programming language)">Scheme</a> dialect of Lisp (R<sup>5</sup>RS and later): </p> <div class="mw-highlight mw-highlight-lang-scheme mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">;; Define some simple form as in the above example.</span> <span class="p">(</span><span class="k">define</span><span class="w"> </span><span class="nv">form2</span><span class="w"> </span><span class="o">'</span><span class="p">(</span><span class="nb">+</span><span class="w"> </span><span class="mi">5</span><span class="w"> </span><span class="mi">2</span><span class="p">))</span> <span class="c1">;Value: form2</span> <span class="c1">;; Evaluate the form within the initial context.</span> <span class="c1">;; A context for evaluation is called an "environment" in Scheme slang.</span> <span class="p">(</span><span class="nb">eval</span><span class="w"> </span><span class="nv">form2</span><span class="w"> </span><span class="nv">user-initial-environment</span><span class="p">)</span> <span class="c1">;Value: 7</span> <span class="c1">;; Confuse the initial environment, so that + will be</span> <span class="c1">;; a name for the subtraction function.</span> <span class="p">(</span><span class="nf">environment-define</span><span class="w"> </span><span class="nv">user-initial-environment</span><span class="w"> </span><span class="ss">'+</span><span class="w"> </span><span class="nb">-</span><span class="p">)</span> <span class="c1">;Value: +</span> <span class="c1">;; Evaluate the form again.</span> <span class="c1">;; Notice that the returned value has changed.</span> <span class="p">(</span><span class="nb">eval</span><span class="w"> </span><span class="nv">form2</span><span class="w"> </span><span class="nv">user-initial-environment</span><span class="p">)</span> <span class="c1">;Value: 3</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Perl">Perl</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=8" title="Edit section: Perl"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/Perl" title="Perl">Perl</a>, the <code>eval</code> function is something of a hybrid between an expression evaluator and a statement executor. It returns the result of the last expression evaluated (all statements are expressions in Perl programming), and allows the final semicolon to be left off. </p><p>Example as an expression evaluator: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span> <span class="k">print</span><span class="w"> </span><span class="nb">eval</span><span class="p">(</span><span class="s">'$foo + 2'</span><span class="p">),</span><span class="w"> </span><span class="s">"\n"</span><span class="p">;</span> </pre></div> <p>Example as a statement executor: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span> <span class="nb">eval</span><span class="p">(</span><span class="s">'$foo += 2; print "$foo\n";'</span><span class="p">);</span> </pre></div> <p><a href="/wiki/Perl" title="Perl">Perl</a> also has <code>eval</code> <i>blocks</i>, which serves as its <a href="/wiki/Exception_handling" title="Exception handling">exception handling</a> mechanism (see <a href="/wiki/Exception_handling_syntax#Perl" title="Exception handling syntax">Exception handling syntax#Perl</a>). This differs from the above use of <code>eval</code> with strings in that code inside <code>eval</code> blocks is interpreted at compile-time instead of run-time, so it is not the meaning of <code>eval</code> used in this article. </p> <div class="mw-heading mw-heading3"><h3 id="PHP">PHP</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=9" title="Edit section: PHP"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/PHP" title="PHP">PHP</a>, <code>eval</code> executes code in a string almost exactly as if it had been put in the file instead of the call to <code>eval()</code>. The only exception is that errors are reported as coming from a call to <code>eval()</code>, and return statements become the result of the function. </p><p>Unlike some languages, the argument to <code>eval</code> must be a string of one or more complete statements, not just expressions; however, one can get the "expression" form of <code>eval</code> by putting the expression in a return statement, which causes <code>eval</code> to return the result of that expression. </p><p>Unlike some languages, PHP's <code>eval</code> is a "language construct" rather than a function,<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> and so cannot be used in some contexts where functions can be, like higher-order functions. </p><p>Example using echo: </p> <div class="mw-highlight mw-highlight-lang-php mw-content-ltr" dir="ltr"><pre><span></span><span class="cp"><?php</span> <span class="nv">$foo</span> <span class="o">=</span> <span class="s2">"Hello, world!</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span> <span class="k">eval</span><span class="p">(</span><span class="s1">'echo "$foo";'</span><span class="p">);</span> <span class="cp">?></span> </pre></div> <p>Example returning a value: </p> <div class="mw-highlight mw-highlight-lang-php mw-content-ltr" dir="ltr"><pre><span></span><span class="cp"><?php</span> <span class="nv">$foo</span> <span class="o">=</span> <span class="s2">"Goodbye, world!</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span> <span class="c1">//does not work in PHP5</span> <span class="k">echo</span> <span class="k">eval</span><span class="p">(</span><span class="s1">'return $foo;'</span><span class="p">);</span> <span class="cp">?></span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Lua">Lua</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=10" title="Edit section: Lua"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/Lua_(programming_language)" title="Lua (programming language)">Lua</a> 5.1, <code>loadstring</code> compiles Lua code into an anonymous function. </p><p>Example as an expression evaluator: </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="n">loadstring</span><span class="p">(</span><span class="s2">"print('Hello World!')"</span><span class="p">)()</span> </pre></div> <p>Example to do the evaluation in two steps: </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">f</span> <span class="o">=</span> <span class="n">loadstring</span><span class="p">(</span><span class="s2">"return a + 1"</span><span class="p">)</span> <span class="c1">-- compile the expression to an anonymous function</span> <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="p">())</span> <span class="c1">-- execute (and print the result '2')</span> </pre></div> <p>Lua 5.2 deprecates <code>loadstring</code> in favor of the existing <code>load</code> function, which has been augmented to accept strings. In addition, it allows providing the function's environment directly, as environments are now <a href="/wiki/Closure_(computer_science)" class="mw-redirect" title="Closure (computer science)">upvalues</a>. </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="nb">load</span><span class="p">(</span><span class="s2">"print('Hello ' .. a)"</span><span class="p">,</span> <span class="s2">""</span><span class="p">,</span> <span class="s2">"t"</span><span class="p">,</span> <span class="p">{</span> <span class="n">a</span> <span class="o">=</span> <span class="s2">"World!"</span><span class="p">,</span> <span class="nb">print</span> <span class="o">=</span> <span class="nb">print</span> <span class="p">})()</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="PostScript">PostScript</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=11" title="Edit section: PostScript"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/PostScript" title="PostScript">PostScript</a>'s <code>exec</code> operator takes an operand — if it is a simple literal it pushes it back on the stack. If one takes a string containing a PostScript expression however, one can convert the string to an executable which then can be executed by the interpreter, for example: </p> <div class="mw-highlight mw-highlight-lang-postscript mw-content-ltr" dir="ltr"><pre><span></span><span class="s">((Hello World) =)</span><span class="w"> </span><span class="nf">cvx</span><span class="w"> </span><span class="nf">exec</span> </pre></div> <p>converts the PostScript expression </p> <div class="mw-highlight mw-highlight-lang-postscript mw-content-ltr" dir="ltr"><pre><span></span><span class="s">(Hello World)</span><span class="w"> </span><span class="nf">=</span> </pre></div> <p>which pops the string "Hello World" off the stack and displays it on the screen, to have an executable type, then is executed. </p><p>PostScript's <code>run</code> operator is similar in functionality but instead the interpreter interprets PostScript expressions in a file, itself. </p> <div class="mw-highlight mw-highlight-lang-postscript mw-content-ltr" dir="ltr"><pre><span></span><span class="s">(file.ps)</span><span class="w"> </span><span class="nf">run</span> </pre></div> <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=Eval&action=edit&section=12" title="Edit section: Python"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/Python_(language)" class="mw-redirect" title="Python (language)">Python</a>, the <code>eval</code> function in its simplest form evaluates a single expression. </p><p><code>eval</code> example (interactive shell): </p> <div class="mw-highlight mw-highlight-lang-pycon mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span> <span class="gp">>>> </span><span class="nb">eval</span><span class="p">(</span><span class="s1">'x + 1'</span><span class="p">)</span> <span class="go">2</span> <span class="gp">>>> </span><span class="nb">eval</span><span class="p">(</span><span class="s1">'x'</span><span class="p">)</span> <span class="go">1</span> </pre></div> <p>The <code>eval</code> function takes two optional arguments, <code>global</code> and <code>locals</code>, which allow the programmer to set up a restricted environment for the evaluation of the expression. </p><p>The <code>exec</code> statement (or the <code>exec</code> function in Python 3.x) executes statements: </p><p><code>exec</code> example (interactive shell): </p> <div class="mw-highlight mw-highlight-lang-pycon mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span> <span class="gp">>>> </span><span class="n">y</span> <span class="o">=</span> <span class="mi">1</span> <span class="gp">>>> </span><span class="n">exec</span> <span class="s2">"x += 1; y -= 1"</span> <span class="gp">>>> </span><span class="n">x</span> <span class="go">2</span> <span class="gp">>>> </span><span class="n">y</span> <span class="go">0</span> </pre></div> <p>The most general form for evaluating statements/expressions is using code objects. Those can be created by invoking the <code>compile()</code> function and by telling it what kind of input it has to compile: an "<code>exec</code>" statement, an "<code>eval</code>" statement or a "<code>single</code>" statement: </p><p><code>compile</code> example (interactive shell): </p> <div class="mw-highlight mw-highlight-lang-pycon mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span> <span class="gp">>>> </span><span class="n">y</span> <span class="o">=</span> <span class="mi">2</span> <span class="gp">>>> </span><span class="nb">eval</span> <span class="p">(</span><span class="nb">compile</span> <span class="p">(</span><span class="s2">"print 'x + y = ', x + y"</span><span class="p">,</span> <span class="s2">"compile-sample.py"</span><span class="p">,</span> <span class="s2">"single"</span><span class="p">))</span> <span class="go">x + y = 3</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="D">D</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=13" title="Edit section: D"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/D_programming" class="mw-redirect" title="D programming">D</a> is a statically compiled language and therefore does not include an "<code>eval</code>" statement in the traditional sense, but does include the related "<code>mixin</code>" statement. The difference is that, where "<code>eval</code>" interprets a string as code at runtime, with a "<code>mixin</code>" the string is statically compiled like ordinary code and must be known at compile time. For example: </p> <div class="mw-highlight mw-highlight-lang-d mw-content-ltr" dir="ltr"><pre><span></span><span class="k">import</span><span class="w"> </span><span class="n">std</span><span class="p">.</span><span class="n">stdio</span><span class="p">;</span> <span class="kt">void</span><span class="w"> </span><span class="n">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">num</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> <span class="w"> </span><span class="k">mixin</span><span class="p">(</span><span class="s">"num++;"</span><span class="p">);</span> <span class="w"> </span><span class="n">writeln</span><span class="p">(</span><span class="n">num</span><span class="p">);</span><span class="w"> </span><span class="c1">// Prints 1.</span> <span class="p">}</span> </pre></div> <p>The above example will compile to exactly the same assembly language instructions as if "<code>num++;</code>" had been written directly instead of mixed in. The argument to mixin doesn't need to be a string literal, but arbitrary expressions resulting in a string value, including function calls, that can be evaluated at compile time. </p> <div class="mw-heading mw-heading3"><h3 id="ColdFusion">ColdFusion</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=14" title="Edit section: ColdFusion"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/ColdFusion" class="mw-redirect" title="ColdFusion">ColdFusion</a>'s <code>evaluate</code> function lets you evaluate a string expression at runtime. </p> <div class="mw-highlight mw-highlight-lang-cfm mw-content-ltr" dir="ltr"><pre><span></span><span class="nb"><cfset</span> <span class="nv">x</span> <span class="o">=</span> <span class="s2">"int(1+1)"</span><span class="nb">></span> <span class="nb"><cfset</span> <span class="nv">y</span> <span class="o">=</span> <span class="nf">Evaluate</span><span class="p">(</span><span class="nv">x</span><span class="p">)</span><span class="nb">></span> </pre></div> <p>It is particularly useful when you need to programmatically choose the variable you want to read from. </p> <div class="mw-highlight mw-highlight-lang-cfm mw-content-ltr" dir="ltr"><pre><span></span><span class="nb"><cfset</span> <span class="nv">x</span> <span class="o">=</span> <span class="nf">Evaluate</span><span class="p">(</span><span class="s2">"queryname.</span><span class="s s-Interp">#columnname#</span><span class="s2">[rownumber]"</span><span class="p">)</span><span class="nb">></span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Ruby">Ruby</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=15" title="Edit section: Ruby"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The <a href="/wiki/Ruby_(programming_language)" title="Ruby (programming language)">Ruby programming language</a> interpreter offers an <code>eval</code> function similar to Python or Perl, and also allows a <a href="/wiki/Scope_(programming)" class="mw-redirect" title="Scope (programming)">scope</a>, or <a href="/wiki/Name_binding" title="Name binding">binding</a>, to be specified. </p><p>Aside from specifying a function's binding, <code>eval</code> may also be used to evaluate an expression within a specific class definition binding or object instance binding, allowing classes to be extended with new methods specified in strings. </p> <div class="mw-highlight mw-highlight-lang-ruby mw-content-ltr" dir="ltr"><pre><span></span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span> <span class="nb">eval</span><span class="p">(</span><span class="s1">'a + 1'</span><span class="p">)</span><span class="w"> </span><span class="c1"># (evaluates to 2)</span> <span class="c1"># evaluating within a context</span> <span class="k">def</span><span class="w"> </span><span class="nf">get_binding</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="w"> </span><span class="nb">binding</span> <span class="k">end</span> <span class="nb">eval</span><span class="p">(</span><span class="s1">'a+1'</span><span class="p">,</span><span class="n">get_binding</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span><span class="w"> </span><span class="c1"># (evaluates to 4, because 'a' in the context of get_binding is 3)</span> </pre></div> <div class="mw-highlight mw-highlight-lang-ruby mw-content-ltr" dir="ltr"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">Test</span><span class="p">;</span><span class="w"> </span><span class="k">end</span> <span class="no">Test</span><span class="o">.</span><span class="n">class_eval</span><span class="p">(</span><span class="s2">"def hello; return 'hello';end"</span><span class="p">)</span><span class="w"> </span><span class="c1"># add a method 'hello' to this class</span> <span class="no">Test</span><span class="o">.</span><span class="n">new</span><span class="o">.</span><span class="n">hello</span><span class="w"> </span><span class="c1"># evaluates to "hello"</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Forth">Forth</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=16" title="Edit section: Forth"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most standard implementations of <a href="/wiki/Forth_(programming_language)" title="Forth (programming language)">Forth</a> have two variants of <code>eval</code>: <code>EVALUATE</code> and <code>INTERPRET</code>. </p><p>Win32FORTH code example: </p> <div class="mw-highlight mw-highlight-lang-forth mw-content-ltr" dir="ltr"><pre><span></span><span class="s">S"</span><span class="w"> </span><span class="s">2 2 + .</span><span class="nf">"</span><span class="w"> </span><span class="k">EVALUATE</span><span class="w"> </span><span class="c1">\ Outputs "4"</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="BASIC">BASIC</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=17" title="Edit section: BASIC"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading4"><h4 id="REALbasic">REALbasic</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=18" title="Edit section: REALbasic"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/REALbasic_programming_language" class="mw-redirect" title="REALbasic programming language">REALbasic</a>, there is a class called <a href="/wiki/RBScript" class="mw-redirect" title="RBScript">RBScript</a> which can execute REALbasic code at runtime. RBScript is very sandboxed—only the most core language features are there, and you have to allow it access to things you want it to have. You can optionally assign an object to the context property. This allows for the code in RBScript to call functions and use properties of the context object. However, it is still limited to only understanding the most basic types, so if you have a function that returns a Dictionary or MySpiffyObject, RBScript will be unable to use it. You can also communicate with your RBScript through the Print and Input events. </p> <div class="mw-heading mw-heading4"><h4 id="VBScript">VBScript</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=19" title="Edit section: VBScript"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Microsoft's VBScript, which is an interpreted language, has two constructs. <code>Eval</code> is a function evaluator that can include calls to user-defined functions. (These functions may have side-effects such as changing the values of global variables.) <code>Execute</code> executes one or more colon-separated statements, which can change global state. </p><p>Both VBScript and JScript <code>eval</code> are available to developers of compiled Windows applications (written in languages which do not support Eval) through an ActiveX control called the Microsoft Script Control, whose Eval method can be called by application code. To support calling of user-defined functions, one must first initialize the control with the AddCode method, which loads a string (or a string resource) containing a library of user-defined functions defined in the language of one's choice, prior to calling Eval. </p> <div class="mw-heading mw-heading4"><h4 id="Visual_Basic_for_Applications">Visual Basic for Applications</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=20" title="Edit section: Visual Basic for Applications"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Visual_Basic_for_Applications" title="Visual Basic for Applications">Visual Basic for Applications</a> (VBA), the programming language of Microsoft Office, is a virtual machine language where the runtime environment compiles and runs <a href="/wiki/Byte_code" class="mw-redirect" title="Byte code">p-code</a>. Its flavor of Eval supports only expression evaluation, where the expression may include user-defined functions and objects (but not user-defined variable names). Of note, the evaluator is different from VBS, and invocation of certain user-defined functions may work differently in VBA than the identical code in VBScript. </p> <div class="mw-heading mw-heading3"><h3 id="Smalltalk">Smalltalk</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=21" title="Edit section: Smalltalk"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>As <a href="/wiki/Smalltalk" title="Smalltalk">Smalltalk</a>'s compiler classes are part of the standard class library and usually present at run time, these can be used to evaluate a code string. </p> <div class="mw-highlight mw-highlight-lang-smalltalk mw-content-ltr" dir="ltr"><pre><span></span><span class="nc">Compiler</span> <span class="nf">evaluate:</span><span class="s">'1 + 2'</span> </pre></div> <p>Because class and method definitions are also implemented by message-sends (to class objects), even code changes are possible: </p> <div class="mw-highlight mw-highlight-lang-smalltalk mw-content-ltr" dir="ltr"><pre><span></span><span class="nc">Compiler</span> <span class="nf">evaluate:</span><span class="s">'Object subclass:#Foo'</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Tcl">Tcl</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=22" title="Edit section: Tcl"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The <a href="/wiki/Tcl" title="Tcl">Tcl</a> programming language has a command called <code>eval</code>, which executes the source code provided as an argument. Tcl represents all source code as strings, with curly braces acting as quotation marks, so that the argument to <code>eval</code> can have the same formatting as any other source code. </p> <div class="mw-highlight mw-highlight-lang-tcl mw-content-ltr" dir="ltr"><pre><span></span><span class="k">set</span><span class="w"> </span>foo<span class="w"> </span><span class="k">{</span> <span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="k">{[</span><span class="nb">incr</span><span class="w"> </span>i<span class="k">]</span><span class="o"><</span><span class="nv">10</span><span class="k">}</span><span class="w"> </span><span class="k">{</span> <span class="w"> </span><span class="nb">puts</span><span class="w"> </span><span class="s2">"$i squared is [expr $i*$i]"</span> <span class="w"> </span><span class="k">}</span> <span class="k">}</span> <span class="k">eval</span><span class="w"> </span><span class="nv">$foo</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="bs">bs</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=23" title="Edit section: bs"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Bs_(programming_language)" title="Bs (programming language)">bs</a> has an <code>eval</code> function that takes one string argument. The function is both an expression evaluator and a statement executor. In the latter role, it can also be used for error handling. The following examples and text are from the <code>bs</code> <a href="/wiki/Man_page" title="Man page">man page</a> as appears in the <a href="/wiki/UNIX_System_V" title="UNIX System V">UNIX System V</a> Release 3.2 Programmer's Manual.<sup id="cite_ref-SVR32_6-0" class="reference"><a href="#cite_note-SVR32-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> </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 string argument is evaluated as a <code>bs</code> expression. The function is handy for converting numeric strings to numeric internal form. The <code>eval</code> can also be used as a crude form of indirection, as in the following (Note that, in <code>bs</code>, <code>_</code> (underscore) is the concatenation operator.): </p><div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"xyz"</span> eval<span class="o">(</span><span class="s2">"++"</span><span class="w"> </span>_<span class="w"> </span>name<span class="o">)</span> </pre></div> <p>which increments the variable <code>xyz</code>. </p><p>In addition, <code>eval</code> preceded by the interrogation operator, <code>?</code>, permits the user to control <code>bs</code> error conditions. For example: </p> <div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span>?eval<span class="o">(</span><span class="s2">"open(\"X\", \"XXX\", \"r\")"</span><span class="o">)</span> </pre></div> <p>returns the value zero if there is no file named "XXX" (instead of halting the user's program). </p><p>The following executes a <code>goto</code> to the label <code>L</code> (if it exists): </p> <div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"L"</span> <span class="k">if</span><span class="w"> </span>!<span class="o">(</span>?eval<span class="o">(</span><span class="s2">"goto "</span><span class="w"> </span>_<span class="w"> </span>label<span class="o">))</span><span class="w"> </span><span class="nv">puterr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"no label"</span> </pre></div></blockquote> <div class="mw-heading mw-heading2"><h2 id="Command-line_interpreters">Command-line interpreters</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=24" title="Edit section: Command-line interpreters"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Unix_shells">Unix shells</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=25" title="Edit section: Unix shells"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The <i>eval</i> command is present in all <a href="/wiki/Unix_shell" title="Unix shell">Unix shells</a>, including the original "sh" (<a href="/wiki/Bourne_shell" title="Bourne shell">Bourne shell</a>). It concatenates all the arguments with spaces, then re-parses and executes the result as a command. <span class="plainlinksneverexpand"><code><a rel="nofollow" class="external text" href="https://www.freebsd.org/cgi/man.cgi?query=sh&sektion=1">sh(1)</a></code></span> – <a href="/wiki/FreeBSD" title="FreeBSD">FreeBSD</a> General Commands <a href="/wiki/Man_page" title="Man page">Manual</a> </p> <div class="mw-heading mw-heading3"><h3 id="PowerShell">PowerShell</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=26" title="Edit section: PowerShell"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/PowerShell" title="PowerShell">PowerShell</a>, the <code>Invoke-Expression</code> Cmdlet serves the same purpose as the eval function in programming languages like JavaScript, PHP and Python. The Cmdlet runs any PowerShell expression that is provided as a command parameter in the form of a string and outputs the result of the specified expression. Usually, the output of the Cmdlet is of the same type as the result of executing the expression. However, if the result is an empty array, it outputs <code>$null</code>. In case the result is a single-element array, it outputs that single element. Similar to JavaScript, PowerShell allows the final semicolon to be left off. </p><p>Example as an expression evaluator: </p> <div class="mw-highlight mw-highlight-lang-ps1con mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">PS > </span><span class="nv">$foo</span> <span class="p">=</span> <span class="n">2</span> <span class="gp">PS > </span><span class="nb">Invoke-Expression</span> <span class="s1">'$foo + 2'</span> </pre></div> <p>Example as a statement executor: </p> <div class="mw-highlight mw-highlight-lang-ps1con mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">PS > </span><span class="nv">$foo</span> <span class="p">=</span> <span class="n">2</span> <span class="gp">PS > </span><span class="nb">Invoke-Expression</span> <span class="s1">'$foo += 2; $foo'</span> </pre></div> <div class="mw-heading mw-heading2"><h2 id="Microcode">Microcode</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=27" title="Edit section: Microcode"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In 1966 <a href="/wiki/IBM" title="IBM">IBM</a> <a href="/wiki/Conversational_Programming_System" title="Conversational Programming System">Conversational Programming System</a> (CPS) introduced a <a href="/wiki/Microcode" title="Microcode">microprogrammed</a> function <code>EVAL</code> to perform "interpretive evaluation of expressions which are written in a modified <a href="/wiki/Polish_notation" title="Polish notation">Polish-string notation</a>" on an <a href="/wiki/IBM_System/360_Model_50" title="IBM System/360 Model 50">IBM System/360 Model 50</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> Microcoding this function was "substantially more" than five times faster compared to a program that interpreted an <a href="/wiki/Assignment_(computer_science)" title="Assignment (computer science)">assignment</a> statement.<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> <div class="mw-heading mw-heading2"><h2 id="Theory">Theory</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=28" title="Edit section: Theory"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In <a href="/wiki/Theoretical_computer_science" title="Theoretical computer science">theoretical computer science</a>, a careful distinction is commonly made between eval and <a href="/wiki/Apply" title="Apply">apply</a>. <i>Eval</i> is understood to be the step of converting a quoted string into a callable function and its arguments, whereas <i>apply</i> is the actual call of the function with a given set of arguments. The distinction is particularly noticeable in <a href="/wiki/Functional_language" class="mw-redirect" title="Functional language">functional languages</a>, and languages based on <a href="/wiki/Lambda_calculus" title="Lambda calculus">lambda calculus</a>, such as <a href="/wiki/LISP" class="mw-redirect" title="LISP">LISP</a> and <a href="/wiki/Scheme_(programming_language)" title="Scheme (programming language)">Scheme</a>. Thus, for example, in Scheme, the distinction is between </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">eval</span><span class="w"> </span><span class="o">'</span><span class="p">(</span><span class="nv">f</span><span class="w"> </span><span class="nv">x</span><span class="p">)</span><span class="w"> </span><span class="p">)</span> </pre></div> <p>where the form (f x) is to be evaluated, and </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">apply</span><span class="w"> </span><span class="nv">f</span><span class="w"> </span><span class="p">(</span><span class="nb">list</span><span class="w"> </span><span class="nv">x</span><span class="p">))</span> </pre></div> <p>where the function <i>f</i> is to be called with argument <i>x</i>. </p><p><i>Eval</i> and <i>apply</i> are the two interdependent components of the <i>eval-apply cycle</i>, which is the essence of evaluating Lisp, described in <a href="/wiki/Structure_and_Interpretation_of_Computer_Programs" title="Structure and Interpretation of Computer Programs">SICP</a>.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> </p><p>In <a href="/wiki/Category_theory" title="Category theory">category theory</a>, the <i>eval</i> <a href="/wiki/Morphism" title="Morphism">morphism</a> is used to define the <a href="/wiki/Closed_monoidal_category" title="Closed monoidal category">closed monoidal category</a>. Thus, for example, the <a href="/wiki/Category_of_sets" title="Category of sets">category of sets</a>, with functions taken as morphisms, and the <a href="/wiki/Cartesian_product" title="Cartesian product">cartesian product</a> taken as the <a href="/wiki/Product_(category_theory)" title="Product (category theory)">product</a>, forms a <a href="/wiki/Cartesian_closed_category" title="Cartesian closed category">Cartesian closed category</a>. Here, <i>eval</i> (or, properly speaking, <i><a href="/wiki/Apply" title="Apply">apply</a></i>) together with its <a href="/wiki/Right_adjoint" class="mw-redirect" title="Right adjoint">right adjoint</a>, <a href="/wiki/Currying" title="Currying">currying</a>, form the <a href="/wiki/Simply_typed_lambda_calculus" title="Simply typed lambda calculus">simply typed lambda calculus</a>, which can be interpreted to be the morphisms of Cartesian closed categories. </p> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=29" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a href="/wiki/Data_as_code" class="mw-redirect" title="Data as code">Data as code</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=Eval&action=edit&section=30" 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"><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://web.archive.org/web/20061010123451/http://livedocs.macromedia.com/flash/8/index.html">"Flash 8 LiveDocs"</a>. 2006-10-10. Archived from <a rel="nofollow" class="external text" href="http://livedocs.macromedia.com/flash/8/index.html">the original</a> on 2006-10-10.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Flash+8+LiveDocs&rft.date=2006-10-10&rft_id=http%3A%2F%2Flivedocs.macromedia.com%2Fflash%2F8%2Findex.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEval" class="Z3988"></span></span> </li> <li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://eval.hurlant.com">ActionScript 3 Eval Library</a></span> </li> <li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20130314012753/http://www.riaone.com/products/deval/">"The D.eval API"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.riaone.com/products/deval/">the original</a> on 2013-03-14.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=The+D.eval+API&rft_id=http%3A%2F%2Fwww.riaone.com%2Fproducts%2Fdeval%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEval" class="Z3988"></span></span> </li> <li id="cite_note-mccarthy-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-mccarthy_4-0">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www-formal.stanford.edu/jmc/history/lisp/node3.html">John McCarthy, "History of Lisp - The Implementation of Lisp"</a></span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://php.net/eval">"PHP: eval - Manual"</a>. <i><a href="/wiki/PHP" title="PHP">PHP</a>.net</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2015-09-10</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=PHP.net&rft.atitle=PHP%3A+eval+-+Manual&rft_id=http%3A%2F%2Fphp.net%2Feval&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEval" class="Z3988"></span></span> </li> <li id="cite_note-SVR32-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-SVR32_6-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1">"Volume 1 Commands and Utilities". <a rel="nofollow" class="external text" href="http://bitsavers.trailing-edge.com/pdf/att/unix/System_V_Release_2/UNIX_Programmers_Manual_Vol_1_Commands_and_Utilities_1986.pdf"><i>UNIX Programmer's Manual</i></a> <span class="cs1-format">(PDF)</span>. AT&T. 1986. p. 41.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=Volume+1+Commands+and+Utilities&rft.btitle=UNIX+Programmer%27s+Manual&rft.pages=41&rft.pub=AT%26T&rft.date=1986&rft_id=http%3A%2F%2Fbitsavers.trailing-edge.com%2Fpdf%2Fatt%2Funix%2FSystem_V_Release_2%2FUNIX_Programmers_Manual_Vol_1_Commands_and_Utilities_1986.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEval" 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="CITEREFAllen-Babcock" class="citation web cs1">Allen-Babcock. <a rel="nofollow" class="external text" href="http://bitsavers.trailing-edge.com/pdf/allen-babcock/cps/Draft_Eval_Microprogram_Mar66.pdf">"Draft EVAL Microprogram"</a> <span class="cs1-format">(PDF)</span>. <i>Bitsavers.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">Jan 17,</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Bitsavers.org&rft.atitle=Draft+EVAL+Microprogram&rft.au=Allen-Babcock&rft_id=http%3A%2F%2Fbitsavers.trailing-edge.com%2Fpdf%2Fallen-babcock%2Fcps%2FDraft_Eval_Microprogram_Mar66.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEval" 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="CITEREFRochester" class="citation web cs1">Rochester, Nathaniel. <a rel="nofollow" class="external text" href="http://bitsavers.trailing-edge.com/pdf/allen-babcock/cps/CPS_Progress_Report_may66.pdf">"Conversational Programming System Progress Report"</a> <span class="cs1-format">(PDF)</span>. <i>Bitsavers.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">Jan 17,</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Bitsavers.org&rft.atitle=Conversational+Programming+System+Progress+Report&rft.aulast=Rochester&rft.aufirst=Nathaniel&rft_id=http%3A%2F%2Fbitsavers.trailing-edge.com%2Fpdf%2Fallen-babcock%2Fcps%2FCPS_Progress_Report_may66.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEval" class="Z3988"></span></span> </li> <li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html">The Metacircular Evaluator</a> (SICP Section 4.1)</span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Eval&action=edit&section=31" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20030322002401/http://www.cs.queensu.ca/software_docs/gnudev/gcl-ansi/gcl_256.html">ANSI and GNU Common Lisp Document: eval function</a></li> <li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20080930143344/http://docs.python.org/lib/built-in-funcs.html#l2h-25">Python Library Reference: eval built-in function</a></li> <li><a rel="nofollow" class="external text" href="http://www.nilobject.com/?p=138">Jonathan Johnson on exposing classes to RBScript</a></li> <li><a rel="nofollow" class="external text" href="https://rosettacode.org/wiki/Runtime_evaluation">Examples of runtime evaluation in several languages</a> on <a href="/wiki/Rosetta_Code" title="Rosetta Code">Rosetta Code</a></li></ul> <!-- NewPP limit report Parsed by mw‐api‐ext.codfw.main‐7556f8b5dd‐6nrfn Cached time: 20241122142452 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.313 seconds Real time usage: 0.951 seconds Preprocessor visited node count: 999/1000000 Post‐expand include size: 11474/2097152 bytes Template argument size: 1852/2097152 bytes Highest expansion depth: 11/100 Expensive parser function count: 38/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 43249/5000000 bytes Lua time usage: 0.153/10.000 seconds Lua memory usage: 3865107/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 890.794 1 -total 16.27% 144.924 1 Template:Quote 16.24% 144.707 1 Template:Reflist 13.34% 118.805 5 Template:Cite_web 11.26% 100.293 1 Template:Short_description 6.50% 57.919 2 Template:Pagetype 3.52% 31.356 4 Template:Main_other 3.46% 30.780 1 Template:Redirects 3.20% 28.505 1 Template:SDcat 0.95% 8.421 1 Template:Man --> <!-- Saved in parser cache with key enwiki:pcache:idhash:623831-0!canonical and timestamp 20241122142452 and revision id 1253996606. Rendering was triggered because: api-parse --> </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=Eval&oldid=1253996606">https://en.wikipedia.org/w/index.php?title=Eval&oldid=1253996606</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Categories</a>: <ul><li><a href="/wiki/Category:Control_flow" title="Category:Control flow">Control flow</a></li><li><a href="/wiki/Category:Unix_SUS2008_utilities" title="Category:Unix SUS2008 utilities">Unix SUS2008 utilities</a></li><li><a href="/wiki/Category:IBM_i_Qshell_commands" title="Category:IBM i Qshell commands">IBM i Qshell commands</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></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 28 October 2024, at 23:01<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=Eval&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-7dfb9d98f5-vnslm","wgBackendResponseTime":186,"wgPageParseReport":{"limitreport":{"cputime":"0.313","walltime":"0.951","ppvisitednodes":{"value":999,"limit":1000000},"postexpandincludesize":{"value":11474,"limit":2097152},"templateargumentsize":{"value":1852,"limit":2097152},"expansiondepth":{"value":11,"limit":100},"expensivefunctioncount":{"value":38,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":43249,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 890.794 1 -total"," 16.27% 144.924 1 Template:Quote"," 16.24% 144.707 1 Template:Reflist"," 13.34% 118.805 5 Template:Cite_web"," 11.26% 100.293 1 Template:Short_description"," 6.50% 57.919 2 Template:Pagetype"," 3.52% 31.356 4 Template:Main_other"," 3.46% 30.780 1 Template:Redirects"," 3.20% 28.505 1 Template:SDcat"," 0.95% 8.421 1 Template:Man"]},"scribunto":{"limitreport-timeusage":{"value":"0.153","limit":"10.000"},"limitreport-memusage":{"value":3865107,"limit":52428800}},"cachereport":{"origin":"mw-api-ext.codfw.main-7556f8b5dd-6nrfn","timestamp":"20241122142452","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Eval","url":"https:\/\/en.wikipedia.org\/wiki\/Eval","sameAs":"http:\/\/www.wikidata.org\/entity\/Q940058","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q940058","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":"2004-04-28T22:35:12Z","dateModified":"2024-10-28T23:01:48Z","headline":"function in a programming language, which evaluates a string as though it were an expression and returns a result"}</script> </body> </html>