Expression (computer science)

In computer science, an expression is a syntactic entity in a programming language that may be evaluated to determine its value[1] or fail to terminate, in which case the expression is undefined.[2] It is a combination of one or more constants, variables, functions, and operators that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce ("to return", in a stateful environment) another value. This process, for mathematical expressions, is called evaluation. In simple settings, the resulting value is usually one of various primitive types, such as string, boolean, or numerical (such as integer, floating-point, or complex).

Expressions are often contrasted with statements—syntactic entities that have no value (an instruction).

  1. ^ Mitchell, J. (2002). Concepts in Programming Languages. Cambridge: Cambridge University Press, 3.4.1 Statements and Expressions, p. 26
  2. ^ Maurizio Gabbrielli, Simone Martini (2010). Programming Languages - Principles and Paradigms. Springer London, 6.1 Expressions, p. 120