|
Programming languages generally have a set of operators that are similar to operators in mathematics: they are somehow special functions. In addition to arithmetic operations they often perform boolean operations on truth values and string operations on strings of text. Unlike functions, operators often provide the primitive operations of the language, their name consists of punctuation rather than alphanumeric characters, and they have special infix syntax and irregular parameter passing conventions. The exact terminology, however, varies from language to language. Other listings of programming languages are: Categorical list of programming languages Generational list of programming languages Chronological list of programming languages Note: Esoteric programming languages have been moved to the separate List of esoteric programming languages. ...
In mathematics, an operator is some kind of function; if it comes with a specified type of operand as function domain, it is no more than another way of talking of functions of a given type. ...
In various branches of mathematics and computer science, strings are sequences of various simple objects (symbols, tokens, characters, etc. ...
Infix notation is the arithmetic formula notation known to most people, in which operators are written infix-style between the operands they act on. ...
Conventionally, the computing usage of "operator" goes beyond the set of common arithmetic operators. The C programming language for example also supports operators like &, ++ and sizeof. Operators like sizeof, which are alphanumeric rather than a mathematical symbol or a punctuation character, are sometimes called named operators. See Operators in C and C++. Operators in C are primitive operations of the language that the compiler can fairly directly map into the machine instructions of microprocessors. The C Programming Language, Brian Kernighan and Dennis Ritchie, the original edition that served for many years as an informal specification of the language The C programming language is a standardized imperative computer programming language developed in the early 1970s by Dennis Ritchie for use on the Unix operating system. ...
This is a list of operators in the C++ and C programming languages. ...
In Haskell, any combination of symbols and punctuation can be used as a binary operator. The operation is defined like a function, and precedence and associativity can be set. Operators are a purely syntactic concept. An operator can be used as a function and vice versa by putting the name into parentheses or backticks respectively. In certain programming languages, such as PostScript, the use of the word "operator" has more specific meaning, in that an operator is an executable element in the stack. Because operators here are always written postfix, the need for parentheses is redundant as the way objects are taken from the stack ensures correct evaluation. This is an example of Reverse Polish notation. PostScript (PS) is a page description language used primarily in the electronic and desktop publishing areas. ...
Reverse Polish notation (RPN), also known as postfix notation, was invented by Australian philosopher and computer scientist Charles Hamblin in the mid-1950s, to enable zero-address memory stores. ...
Operator syntax
Computers are mathematical devices, but compilers and interpreters require a full syntactic theory of all operations in order to parse formulae involving any combinations correctly. In particular they depend on operator precedence rules, on order of operations, that are tacitly assumed in mathematical writing. A diagram of the operation of a typical multi-language compiler. ...
Interpreter can mean one of the following: In communication, an interpreter is a person whose role is to facilitate dialogue between two parties that do not use the same language. ...
This article is about the concept of operator precedence. ...
In arithmetic and algebra, certain rules are used for the order in which the operations in expressions are to be evaluated. ...
Operators are binary or unary. Binary operators ("bi" as in "two") have two operands. In "A*B" the * operator has two operands: A and B. In "!B" the "!" operator (meaning boolean NOT) has only one operand, and is therefore a unary operator. The "-" and "+" operators can be both binary and unary, in "-4" or "+4" it denotes a negative or a positive number, in "0-4" it acts as the subtraction operator. Operators have associativity. This defines the correct evaluation order if a sequence of the same operator is used one after another: whether the evaluator will evaluate the left operations first or the right. For example, in 8 - 4 - 2, since subtraction in most languages is left associative, the so that expression evaluates left to right. 8 - 4 is evaluated first making restult 2, and not 6. The ^ operator (sometime written **) is often right associative. So 4^3^2 equals 4^9, not 64^2. - See Infix notation for more information about infix operator syntax.
Infix notation is the arithmetic formula notation known to most people, in which operators are written infix-style between the operands they act on. ...
Operator overloading Main article: Operator overloading In computer programming, operator overloading (less commonly known as operator ad-hoc polymorphism) is a specific case of polymorphism in which some or all of operators like +, = or == are treated as polymorphic functions and as such have different behaviours depending on the types of their arguments. ...
In some programming languages an operator may work with more than one kind of data, (such as in Java where the + operator is used both for the addition of numbers and for the concatenation of strings). Such an operator is said to be overloaded. In languages that support operator overloading by the programmer, such as C++, one can define customized uses for operators; in Prolog, one can also define new operators. Java is an object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1990s. ...
C++ (pronounced see plus plus, IPA: ) is a general-purpose computer programming language. ...
Prolog is a logic programming language. ...
Operand coercion Some languages also allow for the operands of an operator to be implicitly converted or coerced to suitable data types for the operation to occur. For example, in Perl coercion rules lead into 12 + "3.14" producing the result of 15.14. The text "3.14" is converted to the number 3.14 before addition can take place. Further, 12 is an integer and 3.14 is either a floating or fixed point number (a number that has a decimal place in it) so the integer is then converted to a floating point or fixed point number respectively. Perl, also Practical Extraction and Report Language (a backronym, see below) is an interpreted procedural programming language designed by Larry Wall. ...
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. - See Type conversion for more information about coercion.
|