Operator (computer programming)

Construct associated with a mathematical operation in computer programs

The specification of a language will specify the syntax the operators it supports, while languages such as Prolog that support programmer-defined operators require that the syntax be defined by the programmer.

Use of l-values as operator operands is particularly notable in unary increment and decrement operators. In C, for instance, the following statement is legal and well-defined, and depends on the fact that array indexing returns an l-value:

Common examples that differ semantically (by argument passing mode) are boolean operations, which frequently feature short-circuit evaluation: e.g. a short-circuiting conjunction (X AND Y) that only evaluates later arguments if earlier ones are not false, in a language with strict call-by-value functions. This behaves instead similarly to if/then/else.

In the example , the operators are: ">" (greater than), "AND" and "<" (less than).


In the presence of coercions in a language, the programmer must be aware of the specific rules regarding operand types and the operation result type to avoid subtle programming mistakes.

The following table shows the operator features in several programming languages: