eval
Sign in to saveIn some programming languages, eval, short for evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; it may be structured representation of code, such as an abstract syntax tree (like Lisp forms), or of special type such as code (as in Python). The analog for a statement is exec, which executes a string (or code in other format) as if it were a statement; in some la
Wikidata facts
Show 1 more fact
- Stack Exchange tag
- stackoverflow.com/tags/eval
Sources (1)
via Wikidata · CC0
~17 min read
Article
31 sectionsContents
- Security risks
- Implementation
- Programming languages
- ECMAScript
- JavaScript
- ActionScript
- Lisp
- Perl
- PHP
- Lua
- PostScript
- Python
- D
- ColdFusion
- Ruby
- Forth
- BASIC
- REALbasic
- VBScript
- Visual Basic for Applications
- Smalltalk
- Tcl
- bs
- Command-line interpreters
- Unix shells
- PowerShell
- Microcode
- Theory
- See also
- References
- External links
In some programming languages, eval, short for evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; it may be structured representation of code, such as an abstract syntax tree (like Lisp forms), or of special type such as code (as in Python). The analog for a statement is exec, 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 eval or exec is.
== Security risks == Using eval with data from an untrusted source may introduce security vulnerabilities. For instance, assuming that the get_data() function gets data from the Internet, this Python code is insecure: