Operator (computer programming): Difference between revisions

Content deleted Content added
m ru fixed
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5
 
(335 intermediate revisions by more than 100 users not shown)
Line 1:
{{Short description|Basic programming language construct}}
[[Programming languages]] generally have a set of '''operators''' that are similar to [[operator|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 [[literal string|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 notation|infix syntax]] and irregular parameter passing conventions. The exact terminology, however, varies from language to language.
{{refimprove|date=January 2019}}
{{About|operators in computer programming|other uses|Operator (disambiguation)}}
 
In [[computer programming]], an '''operator''' is a [[programming language]] construct that provides functionality that may not be possible to define as a user-defined [[Function (computer programming)|function]] (i.e. [[sizeof]] in [[C (programming language)|C]]) or has [[Syntax (programming languages)|syntax]] different than a function (i.e. [[Infix notation|infix]] addition as in <code>a+b</code>). Like other programming language concepts, ''operator'' has a generally accepted, although debatable meaning among practitioners while at the same time each language gives it specific meaning in that context, and therefore the meaning varies by language.
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.
 
Some operators are represented with symbols {{endash}} characters typically not allowed for a function [[identifier (computer science)|identifier]] {{endash}} to allow for presentation that is more familiar looking than typical function syntax. For example, a function that tests for greater-than could be named <code>gt</code>, but many languages provide an infix symbolic operator so that code looks more familiar. For example, this:
On the other hand, in languages such as [[Haskell programming language|Haskell]] and [[Prolog]], operators are a purely syntactic concept. Any combination of symbols and punctuation can be used as an operator, and its precedence and associativity can be set. While Haskell only allows new binary operators, Prolog allows one to define operators that are either unary or binary and either prefix, infix or postfix. In Haskell, the operator can be defined and applied just like a function and vice versa by the appropriate use of parentheses or backquotes. Analogously in Prolog, ''[[Prolog#Terms|terms]]'' use either operators or normal ''[[functional predicate|functors]]'' and quotes convert between the usages.
 
<!--this is pseudocode; do not use syntaxhighlight lang="something"-->
In certain programming languages, such as [[PostScript programming language|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]].
<code>if gt(x, y) then return</code>
 
Can be:
== Operator syntax ==
 
<code>if x > y then return</code>
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.
 
Some languages allow a language-defined operator to be overridden with user-defined behavior and some allow for user-defined operator symbols.
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 may also differ semantically from functions. For example, [[short-circuit evaluation|short-circuit]] Boolean operations evaluate later arguments only if earlier ones are not false.
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 <tt>8 - 4 - 2</tt>, since subtraction in most languages is left associative, the so that expression evaluates left to right. <tt>8 - 4</tt> is evaluated first making restult 2, and not 6.
 
== Differences from functions ==
The exponentiation operator (typically written as ^ or **) is often right associative. So <tt>4^3^2</tt> equals <tt>4^9</tt>, not <tt>64^2</tt>.
 
=== Syntax ===
: ''See [[Infix notation]] for more information about infix operator syntax.''
Many operators differ syntactically from user-defined functions. In most languages, a function is [[prefix notation]] with fixed [[Order of operations|precedence]] level and associativity and often with compulsory [[parentheses]] (e.g. <code>Func(a)</code> or <code>(Func a)</code> in [[Lisp (programming language)|Lisp]]). In contrast, many operators are infix notation and involve different use of delimiters such as parentheses.
 
In general, an operator may be prefix, infix, postfix, [[matchfix]], [[circumfix]] or bifix,<ref>{{Cite web|url=https://reference.wolfram.com/language/tutorial/OperatorInputForms.html.en|title=Operator Input Forms—Wolfram Language Documentation|website=reference.wolfram.com}}</ref><ref>{{Cite web|url=https://maxima.sourceforge.net/docs/manual/maxima_7.html|title=Maxima 5.42.0 Manual: 7. Operators|website=maxima.sourceforge.net}}</ref><ref>{{Cite web|url=https://mythryl.org/my-Prefix__Postfix_and_Circumfix_Operators.html|title=Prefix, Postfix and Circumfix Operators|website=mythryl.org}}</ref><ref>{{Cite web|url=http://doc.perl6.org/language/operators#___top|title=Operators|website=doc.perl6.org}}</ref><ref name=Pribavkina>{{cite conference|ref= Pribavkina| last1 = Pribavkina| last2= Rodaro| date= August 2010| title= State Complexity of Prefix, Suffix, Bifix and Infix Operators on Regular Languages |journal= Lecture Notes in Computer Science| type= Conference Article| series= Developments in Language Theory| language= English| conference= 14th International Conference on Developments in Language Theory| ___location= London Ontario| publisher= Springer| publication-date= 2010| issue= 6224| pages= 376–377 | doi=10.1007/978-3-642-14455-4_34| isbn= 978-3-642-14454-7| issn= 0302-9743}}</ref> and the syntax of an [[expression (computer science)|expression]] involving an operator depends on its [[arity]] (number of [[operand]]s), precedence, and (if applicable), [[Operator associativity|associativity]]. Most programming languages support [[binary operator]]s and a few [[unary operation|unary operators]], with a few supporting more operands, such as the [[?:]] operator in C, which is ternary. There are prefix unary operators, such as unary minus <code>-x</code>, and postfix unary operators, such as [[post-increment]] <code>x++</code>; and binary operations are infix, such as <code>x + y</code> or <code>x = y</code>. Infix operations of higher arity require additional symbols, such as the [[ternary operator]] ?: in C, written as <code>a ? b : c</code> – indeed, since this is the only common example, it is often referred to as ''the'' ternary operator. Prefix and postfix operations can support any desired arity, however, such as <code>1 2 3 4 +</code>.
== Operator overloading ==
{{main|Operator overloading}}
 
=== Semantics ===
In some programming languages an operator may be ''ad-hoc polymorphic'', that is, have definitions for more than one kind of data, (such as in [[Java programming language|Java]] where the <tt>+</tt> 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 but have a limited set of operators, such as [[C++]], operator overloading is often used to define customized uses for operators.
The semantics of an operator may significantly differ from that of a normal function. For reference, addition is evaluated like a normal function. For example, <code>x + y</code> can be equivalent to a function <code>add(x, y)</code> in that the arguments are evaluated and then the functional behavior is applied. However, [[Assignment_(computer_science)|assignment]] is different. For example, given <code>a = b</code> the target <code>a</code> is ''not'' evaluated. Instead its value is replaced with the value of <code>b</code>. The [[scope resolution operator|scope resolution]] and element access operators (as in <code>Foo::Bar</code> and <code>a.b</code>, respectively, in the case of e.g. [[C++]]) operate on identifier names; not values.
 
In C, for instance, the array indexing operator can be used for both read access as well as assignment. In the following example, the [[increment and decrement operators|increment operator]] reads the element value of an array and then assigns the element value.
<syntaxhighlight lang=c>
++a[i];
</syntaxhighlight>
 
The C++ <code>&lt;&lt;</code> operator allows for [[fluent interface|fluent]] syntax by supporting a sequence of operators that affect a single argument. For example:
<syntaxhighlight lang=cpp>
cout << "Hello" << " " << "world!" << endl;
</syntaxhighlight>
 
== ad hoc polymorphic ==
{{further|Ad hoc polymorphism}}
Some languages provide operators that are '''ad hoc polymorphic''' {{endash}} inherently overloaded. For example, in [[Java (programming language)|Java]] the {{code|+}} operator sums [[number]]s or [[concatenate]]s [[String (computer science)|strings]].
 
== Customization ==
Some languages support user-defined [[operator overloading|overloading]] (such as [[C++]] and [[Fortran]]). An operator, defined by the language, can be [[function overloading|overloaded]] to behave differently based on the type of input.
 
Some languages (e.g. C, C++ and [[PHP]]) define a fixed set of operators, while others (e.g. [[Prolog]],<ref>{{Cite web|url=https://www.swi-prolog.org/pldoc/man?predicate=op/3|title=SWI-Prolog -- op/3|website=www.swi-prolog.org}}</ref> [[Seed7]],<ref>{{Cite web|url=https://seed7.sourceforge.net/examples/operator.htm|title=Declare an operator|website=seed7.sourceforge.net}}</ref> [[F Sharp (programming language)|F#]], [[OCaml]], [[Haskell]]) allow for user-defined operators. Some programming languages restrict operator symbols to special characters like {{mono|1='''[[Addition|+]]'''}} or {{mono|1='''[[Assignment (computer science)|:=]]'''}} while others allow names like <code>[[Integer_division#Division_of_integers|div]]</code> (e.g. [[Pascal (programming language)|Pascal]]), and even arbitrary names (e.g. [[Fortran]] where an upto 31 character long operator name is enclosed between dots<ref name="IntelFortran">{{cite web |title=Defined Operations |url=https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-0/defined-operations.html |publisher=Intel |access-date=6 May 2025}}</ref>).
 
Most languages do not support user-defined operators since the feature significantly complicates parsing. Introducing a new operator changes the arity and precedence [[lexical specification]] of the language, which affects phrase-level [[lexical analysis]]. Custom operators, particularly via runtime definition, often make correct [[static analysis]] of a program impossible, since the syntax of the language may be Turing-complete, so even constructing the syntax tree may require solving the halting problem, which is impossible. This occurs for [[Perl]], for example, and some dialects of [[Lisp (programming language)|Lisp]].
 
If a language does allow for defining new operators, the mechanics of doing so may involve meta-programming {{endash}} specifying the operator in a separate language.
 
== Operand coercion ==
{{further|Type conversion}}
Some languages implicitly convert (aka [[Type conversion#Implicit type conversion|coerce]]) operands to be compatible with each other. For example, [[Perl]] coercion rules cause <code>12 + "3.14"</code> to evaluate to <code>15.14</code>. The string literal <code>"3.14"</code> is converted to the numeric value 3.14 before addition is applied. Further, <code>3.14</code> is treated as floating point so the result is floating point even though <code>12</code> is an integer literal. [[JavaScript]] follows different rules so that the same expression evaluates to <code>"123.14"</code> since <code>12</code> is converted to a string which is then concatenated with the second operand.
 
In general, a programmer must be aware of the specific rules regarding operand coercion in order to avoid unexpected and incorrect behavior.
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 <tt>12 + "3.14"</tt> producing the result of <tt>15.14</tt>. The text <tt>"3.14"</tt> 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.
 
== Examples ==
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.
{{category see also|Operators (programming)}}
 
;Mathematical operators
: ''See [[Type conversion]] for more information about coercion.''
* [[Arithmetic]]: such as addition, <code>a {{red|+}} b</code>
* [[Relational operator|Relational]]: such as [[Greater-than sign|greater than]], <code>a {{red|&gt;}} b</code>
* [[Mathematical logic|Logic]]: such as <code>a {{red|AND}} b</code> or <code>a {{red|&amp;&amp;}} b</code>
* [[Assignment (computer science)|Assignment]]: such as <code>a {{red|&equals;}} b</code> or <code>a {{red|:&equals;}} b</code>
* [[Three-way comparison]] (aka spaceship): <code>x {{red|&lt;&equals;&gt;}} y</code>
 
;Program structure operators
[[Category:Programming constructs]]
* [[Record (computer science)|Record]] or [[Object (computer science)|object]] [[Field (computer science)|field]] access: such as <code>a{{red|.}}b</code>
* [[scope resolution operator|Scope resolution]]: such as <code>a{{red|::}}b</code> or <code>a{{red|.}}b</code>
 
;Conditional operators
[[he:אופרטור (תכנות)]]
* [[Ternary conditional operator|Ternary conditional]]: <code>condition {{red|?}} a {{red|:}} b</code>
[[ja:&#28436;&#31639;&#23376;]]
* [[Elvis operator|Elvis]]: <code>x {{red|?:}} y</code>
[[pl:Operator (programowanie)]]
* [[Null coalescing operator|Null coalesing]]: <code>x {{red|??}} y</code>
[[ru:Операция (программирование)]]
 
;Notable C and C++ operators
* Address-of operator: <code>{{red|&amp;}}x</code>
* [[Dereference operator|Dereference]]: <code>{{red|*}}p</code>
* [[Comma operator|Comma]]: <code>e{{red|,}} f</code>
 
{{anchor|Compound operator|Fused operation}}
;Compound operators
* [[compound assignment operator|Compound assignment]] (aka augmented assignment) in C/C++: <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code><<=</code>, <code>>>=</code>, <code>&=</code>, <code>^=</code>, <code>|=</code>
* [[fused operation|Fused]]: such as [[cis (mathematics)|{{math|1=cis ''x'' = cos ''x'' + ''i'' sin ''x''}}]]
 
== Operator features in programming languages ==
The following table shows the operator features in several programming languages:
 
{| class="sortable wikitable"
|-
!Language
!Symbolic operators
!Alphanumeric operators
! {{verth|Prefix}}
! {{verth|Infix}}
! {{verth|Postfix}}
! {{verth|Precedence}}
! {{verth|Associativity}}
! {{verth|Overloading}}
! {{verth|User-defined<br/>overloading}}
! {{verth|User-defined<br/>symbols}}
|-
| [[ALGOL 68]] <small>each symbolic operator has an alphanumeric equivalent and some a non-[[ASCII]] equivalent</small>
| {{code|1=+* ** * / % %* %× - + &lt; &lt;= >= > = /= & -:= +:= *:= /:= %:= %*:= +=: :=: :/=:}}
'''non-ASCII:'''
{{code|1=¬ +× ⊥ ↑ ↓ ⌊ ⌈ × ÷ ÷× ÷* □ ≤ ≥ ≠ ∧ ∨ ×:= ÷:= ÷×:= ÷*:= %×:= :≠:}}
| {{code|not abs arg bin entier leng level odd repr round shorten i shl shr up down lwb upb lt le ge gt eq ne and or over mod elem minusab plusab timesab divab overab modab plusto is {{Not a typo|isnt}}}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{Yes}} <small>(prefix operators always have priority 10)</small>
| Infix operators are left associative, prefix operators are right associative
| {{Yes}}
| {{Yes}}
| {{Yes}}
|-
| [[APL (programming language)|APL]]
| {{code|1=+ - × ÷ ⌈ ⌊ * ⍟ <nowiki>|</nowiki> ! ○ ~ ∨ ∧ ⍱ ⍲ &lt; ≤ = ≥ > ≠ . @ ≡ ≢ ⍴ , ⍪ ⍳ ↑ ↓ ? ⍒ ⍋ ⍉ ⌽ ⊖ ∊ ⊥ ⊤ ⍎ ⍕ ⌹ ⊂ ⊃ ∪ ∩ ⍷ ⌷ ∘ → ← / ⌿ \ ⍀ ¨ ⍣ & ⍨ ⌶ ⊆ ⊣ ⊢ ⍠ ⍤ ⌸ ⌺ ⍸}}
| (requires ⎕ prefix)
| {{Yes}} <small>(first-order functions only)</small>
| {{Yes}}
| {{Yes}} <small>(higher-order functions only)</small>
| Higher-order functions precede first-order functions
| Higher-order functions are left associative, first-order functions are right associative
| {{Yes}}
| {{Yes}}
| {{Yes}} <small>(alphanumeric only)</small>
|-
|[[B (programming language)|B]]
|{{code|1=() [] ! ~ ++ -- + - * & / % << >> < <= > >= == != ^ <nowiki>|</nowiki> [[?:]] = =+ =- =* =/ =% =& =^ =<nowiki>|</nowiki>}}<ref>{{Cite web |title=A TUTORIAL INTRODUCTION TO THE LANGUAGE B |url=https://www.bell-labs.com/usr/dmr/www/btut.html |access-date=2024-08-03 |archive-date=2017-04-03 |archive-url=https://web.archive.org/web/20170403063756/https://www.bell-labs.com/usr/dmr/www/btut.html |url-status=dead }}</ref>
|
|{{Yes}}
|{{Yes}}
|{{Yes}}
|{{Yes}}
|{{Yes}}
|{{No}}
|{{No}}
|{{No}}
|-
| [[C (programming language)|C]]
| {{code|1=() [] -> . ! ~ ++ -- + - * & / % << >> < <= > >= == != ^ <nowiki>|</nowiki> && <nowiki>||</nowiki> [[?:]] = += -= *= /= %= &= ^= |= <<= >>=}}
| <code>[[sizeof]]</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{No}}
|-
| [[C++]]
| (same as C)
| (same as C plus) <code>[[typeid]] [[new (C++)|new]] [[delete (C++)|delete]] [[Exception handling|throw]] [[decltype]] [[static_cast]] [[dynamic cast]] [[reinterpret_cast]] [[const_cast]]</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
|-
| [[C sharp (programming language)|C#]]
| (same as C plus) <code>[[?.]] ?[] [[Null coalescing operator|??]] <nowiki>??=</nowiki></code>
| <code>[[sizeof]] nameof new stackalloc await [[Exception handling|throw]] checked unchecked is as delegate default true false</code> <br> '''[[LINQ]]:''' <code>from select where group...by group...by...into join...in...on...equals join...in...on...equals...into orderby orderby...descending</code> <br> '''[[Roslyn (compiler)|Roslyn]]-only:''' <code>__makeref __refvalue __reftype</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
|-
| [[Java (programming language)|Java]]
| (same as C)
| <code>[[Java syntax#Instantiation|new]] [[Exception handling|throw]] [[instanceof]]</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{No}}
|-
| [[Eiffel (programming language)|Eiffel]]
| <code>[] + - * / // = /= </code>
| <code>not and or implies "and then" "or else" </code>
| {{Yes}}
| {{Yes}}
| {{No}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{Yes}}
| {{Yes}}
|-
| [[Haskell]]
|<code>+ - * / ^ ^^ ** == /= > < >= <= && <nowiki>||</nowiki> >>= >> $ $! . ++ !! :</code> <small>(and many more)</small>
| (function name must be in backticks)
| {{Yes}}
| {{Yes}}
| {{No}}
| {{Yes}}
| {{Yes}}
| colspan="2" {{Yes}}, using [[Type class]]es
| {{Yes}}
|-
| [[MultiValue|mvBasic Databasic/Unibasic]]
|<code>+ - * / ^ ** : = ! & [] += -= := # < > <= >= <> >< =< #> => #< </code>
|<code>AND OR NOT EQ NE LT GT LE GE MATCH ADDS() ANDS() CATS() DIVS() EQS() GES() GTS() IFS()</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
|-
| [[Pascal (programming language)|Pascal]]
| <code>* / + - = < > <> <= >= :=</code>
| <code>[[Negation#Programming|not]] [[Integer division#Division of integers|div]] [[Modulo operation|mod]] [[Logical conjunction|and]] [[Logical disjunction|or]] in</code>
| {{Yes}}
| {{Yes}}
| {{No}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{No}}
|-
| [[Perl]]
| <code>-> ++ -- ** ! ~ \ + - . =~ !~ * / % < > <= >= == != <=> ~~ & <nowiki>|</nowiki> ^ &amp;&amp; <nowiki>||</nowiki> ' &apos;&apos; {{Not a typo|// .. ... ?: {{=}} +{{=}} -{{=}} *{{=}} , {{=}}>}} </code>
| <code>print sort chmod chdir rand and or not xor lt gt le ge eq ne cmp x </code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
|-
| [[PHP]]
| <code>[] ** ++ -- ~ @!<ref>{{Cite web|url=https://php.net/manual/en/language.operators.errorcontrol.php|title=PHP: Error Control Operators - Manual|website=php.net}}</ref> * / % + - . << >> < <= > >= == != === !== <> [[Spaceship operator|<=>]] & ^ <nowiki>|</nowiki> && <nowiki>||</nowiki> [[Null coalescing operator|??]] [[?:]] = += -= *= **= /= .= %= &= <nowiki>|=</nowiki> ^= <<= >>= </code>
| <code>clone new unset print echo isset [[instanceof]] [[Logical conjunction|and]] [[Logical disjunction|or]] [[xor]]</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{No}}
| {{No}}
|-
| [[PL/I]]
| <code>( ) -> + - * / ** > ¬> >= = ¬= <= < ¬< ¬ <nowiki>&</nowiki> <nowiki>|</nowiki> <nowiki>||</nowiki></code>
|
| {{Yes}}
| {{Yes}}
| {{No}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{No}}
| {{No}}
|-
| [[Prolog]]
| <code>:- ?- ; , . =.. = \= < =< >= > == \== - + / *</code>
| <code>spy nospy not is mod</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{No}}
| {{Yes}}
|-
| [[Raku (programming language)|Raku]]
| <code>++ -- ** ! ~ ~~ * / + - . < > <= >= == != <=> & <nowiki>|</nowiki> ^ &amp;&amp; <nowiki>||</nowiki> //</code> <ref>{{Cite web|url=https://docs.perl6.org/language/operators|title=Operators|website=docs.perl6.org}}</ref>
| <code>print sort chmod chdir rand and or not xor lt gt le ge eq ne leg cmp x xx</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}<ref>{{Cite web|url=https://docs.perl6.org/language/functions#Defining_Operators|title=Functions|website=docs.perl6.org}}</ref>
|-
| [[Seed7]]
| <code>{} [] -> ** ! + - * / << >> & >< <nowiki>|</nowiki> = <> > >= < <= <& := +:= -:= *:= /:= <<:= >>:= &:= @:=</code>
| <code>conv varConv parse [[Complex conjugate|conj]] [[Integer division#Division of integers|div]] [[Remainder|rem]] [[Modulo operation|mdiv mod]] times mult in [[Negation#Programming|not]] [[Logical conjunction|and]] [[Logical disjunction|or]] digits lpad rpad lpad0</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
|-
| [[Smalltalk]]
| (up to two characters<ref name="BinaryMessages">{{cite web|first=Adele|last=Goldberg|url=http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook.pdf|title=Smalltalk-80: The Language and its Implementation, p. 27, ISBN 0-201-11371-6}}</ref>)
| (alphanumeric symbols need a colon suffix)
| {{No}}
| {{Yes}}
| {{Yes}}
| {{No}}
| {{No}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
|-
| [[Swift (programming language)|Swift]]
| (any Unicode symbol string except) <code>.</code> (including) <code>! ~ + - * / % =+ =- =* =/ =% &+ &- &* =&+ =&- =&* && <nowiki>||</nowiki> << >> & <nowiki>|</nowiki> ^ == != < <= > >= ?? ... ..< </code>
| <code>is as as?</code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}} <small>(defined as partial order in precedence groups)</small>
| {{Yes}} <small>(defined as part of precedence groups)</small>
| {{Yes}}
| {{Yes}}
| {{Yes}}
|-
| [[Visual Basic .NET]]
| rowspan="2" | <code>() . ! ?() ?. ?! + - * / \ & << >> < <= > >= ^ <> = += -= *= /= \= &= ^= <<= >>=</code>
|<code>New Await Mod Like Is IsNot Not And AndAlso Or OrElse Xor If(...,...) If(...,...,...) GetXmlNamespace(...) GetType(...) NameOf(...) TypeOf...Is TypeOf...IsNot DirectCast(...,...) TryCast(...,...) </code> <br> '''[[LINQ]]:''' <code>From Aggregate...Into Select Distinct Where {{nowrap|<Order By>...[Ascending<nowiki>|</nowiki>Descending]}} Take {{nowrap|<Take While>}} Skip {{nowrap|<Skip While>}} Let Group...By...Into Join...On <Group Join...On...Into></code>
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{Yes}}
| {{No}}
|-
|}
 
== See also ==
* [[Operators in C and C++]]
 
== References ==
{{reflist}}
 
[[Category:Operators (programming)| ]]
[[Category:Programming constructs]]