Operator (computer programming)

operatoroperatorsOperator (programming)operationarithmetic operatorsbinary operatorbinary operatorscontrol operatorexpression operatorsoperations
Programming languages typically support a set of operators: constructs which behave generally like functions, but which differ syntactically or semantically from usual functions.wikipedia
156 Related Articles

Assignment (computer science)

assignmentsingle assignmentassignment operator
More involved examples include assignment (usually or ), field access in a record or object (usually ), and the scope resolution operator (often ).
In some languages the symbol used is regarded as an operator (meaning that the assignment statement as a whole returns a value) while others define the assignment as a statement (meaning that it cannot be used in an expression).

Operator associativity

right-associativeleft-associativeassociativity
The position of the operator with respect to its operands may be prefix, infix or postfix, and the syntax of an expression involving an operator depends on its arity (number of operands), precedence, and (if applicable), associativity.
In programming languages, the associativity of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses.

Expression (computer science)

expressionexpressionsevaluation environment
The position of the operator with respect to its operands may be prefix, infix or postfix, and the syntax of an expression involving an operator depends on its arity (number of operands), precedence, and (if applicable), associativity.
An expression in a programming language is a combination of one or more constants, variables, operators, and functions 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.

Increment and decrement operators

Incrementincrement operator++
There are prefix unary operators, such as unary minus, and postfix unary operators, such as post-increment ; and binary operations are infix, such as or.
Increment and decrement operators are unary operators that add or subtract one, to or from their operand, respectively.

Operators in C and C++

operator precedence C and C++
A language may contain a fixed number of built-in operators (e.g. +, -, *, <, <=, !, =, etc. in C and C++, PHP), or it may allow the creation of programmer-defined operators (e.g. Prolog, Seed7, F#, OCaml, Haskell).
This is a list of operators in the C and C++ programming languages.

Ternary operation

ternary operatorternaryternary operators
Infix operations of higher arity require additional symbols, such as the ternary operator ?: in C, written as – indeed, this is the only common example, it is often referred to as the ternary operator.
In computer science, a ternary operator is an operator that takes three arguments.

Prolog

SICStus PrologProlog IISICStus
A language may contain a fixed number of built-in operators (e.g. +, -, *, <, <=, !, =, etc. in C and C++, PHP), or it may allow the creation of programmer-defined operators (e.g. Prolog, Seed7, F#, OCaml, Haskell). 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.
The built-in logical operator (meaning an arity 2 operator with name ) denotes conjunction of goals, and denotes disjunction.

Seed7

its own programming-language interpreterTransport Layer Security
A language may contain a fixed number of built-in operators (e.g. +, -, *, <, <=, !, =, etc. in C and C++, PHP), or it may allow the creation of programmer-defined operators (e.g. Prolog, Seed7, F#, OCaml, Haskell).
For example, programmers can introduce syntax and semantics of new statements and user defined operator symbols.

Evaluation strategy

call by namecall by valuecall-by-name
For example, in assignment the target is not evaluated, but instead its location (address) is used to store the value of – corresponding to call-by-reference semantics.
Under Church encoding, eager evaluation of operators maps to strict evaluation of functions; for this reason, strict evaluation is sometimes called "eager".

Operator overloading

overloadedoverloaded operatorsoverloading
Many languages only allow operators to be used for built-in types, but others allow existing operators to be used for user-defined types; this is known as operator overloading.
In computer programming, operator overloading, sometimes termed operator ad hoc polymorphism, is a specific case of polymorphism, where different operators have different implementations depending on their arguments.

Order of operations

precedenceoperator precedencePrecedence of operators
In most languages, functions may be seen as a special form of prefix operator with fixed precedence level and associativity, often with compulsory parentheses e.g. (or in Lisp).
Some programming languages use precedence levels that conform to the order commonly used in mathematics, though others, such as APL, Smalltalk, Occam and Mary, have no operator precedence rules (in APL, evaluation is strictly right to left; in Smalltalk etc. it is strictly left to right).

Fluent interface

fluent-stylefluent interfaces
This allows a sequence of operators all affecting the original argument, allowing a fluent interface, similar to method cascading.
A common example is the iostream library in C++, which uses the or operators for the message passing, sending multiple data to the same object and allowing "manipulators" for other method calls.

Bracket

parentheses{brackets
In most languages, functions may be seen as a special form of prefix operator with fixed precedence level and associativity, often with compulsory parentheses e.g. (or in Lisp).
The various bracket characters are frequently used in many programming languages as operators or for other syntax markup.

Operand

operandsimmediate
The position of the operator with respect to its operands may be prefix, infix or postfix, and the syntax of an expression involving an operator depends on its arity (number of operands), precedence, and (if applicable), associativity.
In computer programming languages, the definitions of operator and operand are almost the same as in mathematics.

Infix notation

infixinfix operatoralgebraic notation
The position of the operator with respect to its operands may be prefix, infix or postfix, and the syntax of an expression involving an operator depends on its arity (number of operands), precedence, and (if applicable), associativity.

Binary operation

binary operatoroperationbinary
Most programming languages support binary operators and a few unary operators, with a few supporting more operands, such as the ?: operator in C, which is ternary.

Typeof

instance-ofinstanceof
typeof, alternately also typeOf, and TypeOf, is an operator provided by several programming languages to determine the data type of a variable.

Pascal (programming language)

PascalPascal programming languageISO 7185
Some programming languages restrict operator symbols to special characters like + or := while others allow also names like (e.g. Pascal).
The set operators can then be implemented efficiently as bitwise machine code operations.

Unary operation

unaryunary operatormonadic
Most programming languages support binary operators and a few unary operators, with a few supporting more operands, such as the ?: operator in C, which is ternary.

C++

C++ programming languageC++98C with Classes
In languages that support operator overloading by the programmer (such as C++) but have a limited set of operators, operator overloading is often used to define customized uses for operators.
The name comes from C's operator (which increments the value of a variable) and a common naming convention of using "+" to indicate an enhanced computer program.

Modulo operation

modulomodmodulus
Some also support expressions that use "%", "mod", or "Mod" as a modulo or remainder operator, such as

Relational operator

comparisonComparecomparison operator
*Relational operator
In computer science, a relational operator is a programming language construct or operator that tests or defines some kind of relation between two entities.

Language Integrated Query

LINQLINQ to SQLLanguage Integrated Query (LINQ)
The set of query operators defined by LINQ is exposed to the user as the Standard Query Operator (SQO) API.

C (programming language)

CC programming languageC language
C supports a rich set of operators, which are symbols used within an expression to specify the manipulations to be performed while evaluating that expression.

ALGOL 68

Algol68ALGOL-68GOST 27974-88
The programmer may define new operators and both those and the pre-defined ones may be overloaded and their priorities may be changed by the coder.