Operator (computer programming): Difference between revisions

Content deleted Content added
generalized towards haskell
operators in c are primitives
Line 1:
[[Programming languages]] generally have a set of '''[[operator]]s''' that perform arithmetical operations, and others such as boolean operations on truth values, and string operators manipulating [[literal string|strings of text]]. Computers are mathematical devices, but [[compiler]]s and [[interpreter]]s 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.
 
Conventionally, the computing usage of "operator" goes beyond the set of common arithmetic operators. The [[C programming language]] for example also supports operators like <tt>&</tt>, <tt>++</tt> and <tt>sizeof</tt>. Operators like <tt>sizeof</tt>, which are alphanumeric rather than a mathematical symbol or a punctuation character, are sometimes called ''named operators''. See [[Operators in C and C Plus Plus|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.
 
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.