Expression (programming)

from Wikipedia, the free encyclopedia

An expression is in many programming a construct that according to a given semantics in relation to a context analyzed can be, so a value.

In many formal languages, expressions are one of the most important constructs, if not the only one. Some examples:

Arithmetic expressions
2*3; 2(x − a); x2 = 2x; y= sin(x); etc.
Propositional expressions
a und b; wenn b dann a; a oder nicht b; etc.
Predicate logic expressions
wenn verheiratet(A, B) dann verheiratet(B, A); wenn Mensch(A) dann (Mann(A) oder Frau(A)); etc.

Expressions in programming languages

  • Literals (constants) 2, 3.14... (But strings (strings) and symbols: "Hallo Welt", 'c', ...)
  • Variables : x, betragInEuro, wochentagsNummer, ...
  • Features : sin(phi), random(), aktMonatsNummer(), ...
  • Operations : 2*3, 2(x - a), x^3, cos(2*x + 3.14), ...
  • Combined terms, some of them with assignments or expression statements : x++, --y, y = x = 2*z, y = sin(x), ...

In addition to expressions, declarations that define the context for the expressions are important in many formal languages . These are sometimes (especially in functional programming languages and scripting languages ) themselves viewed as expressions.

See also


  • Gert Smolka: Programming - an introduction to computer science with standard M . Second edition, Oldenbourg Verlag, Munich 2011, ISBN 978-3-486-70517-1 .
  • Anatoli Iwanowitsch Kitow: Programming and processing of large amounts of information . BG Verlagsgesellschaft, Leipzig 1972.

Web links