Expression (computer science): Difference between revisions

Content deleted Content added
Use code tags consistently for values in opening paragraph
The value of an expression is a value, not an expression
Line 1:
An '''expression''' in a [[programming language]] is a combination of one or more explicit [[value (computer science)|value]]s, [[Constant (programming)|constants]], [[variable (programming)|variable]]s, [[operator (programming)|operator]]s, and [[function (programming)|function]]s that the programming language interprets (according to its particular [[Order of operations|rules of precedence]] and of association) and computes to produce ("to return", in a [[state (computer science)|stateful]] environment) another value. This process, as for [[mathematical expression]]s, is called evaluation.
 
In simple settings, the [[return type|resulting value]] is usually one of various [[primitive data type|primitive types]], such as numerical, [[string (computer science)|string]], and [[boolean expression|logical]]; in more elaborate settings, it can be an arbitrary [[complex data type]]. In [[functional programming]], the resulting values are often functions or expressions, which can themselves be further evaluated.
 
For example, <code>2+3</code> is an arithmetic and programming expression which evaluates to <code>5</code>. A variable is an expression because it denotes a value in memory, so <code>y+6</code> is an expression. An example of a relational expression is <code>4≠4</code>, which evaluates to <code>false</code>.<ref>[https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Expressions Javascript expressions, Mozilla] Accessed July 6, 2009</ref><ref>[https://www.cs.drexel.edu/~rweaver/COURSES/ISTC-2/TOPICS/expr.html Programming in C] Accessed July 6, 2009</ref>