Operator (computer programming): Difference between revisions

Content deleted Content added
Changing short description from "Programming language construct that provides functionality that is syntactically different from or not possible to express as a user-defined function" to "Basic programming language construct"
Operator features in programming languages: further differentiate via code template
Line 76:
! {{verth|Programmer-defined<br/>overloading}}
! {{verth|Programmer-defined<br/>operator symbols}}
|-
| [[ALGOL 68]] <small>each symbolic operator has an alphanumeric equivalent and some a non-[[ASCII]] equivalent</small>
| {{monocode|1=+* ** * / % %* %× - + &lt; &lt;= >= > = /= & -:= +:= *:= /:= %:= %*:= +=: :=: :/=:}}
('''non-ASCII):'''
{{monocode|1=¬ +× ⊥ ↑ ↓ ⌊ ⌈ × ÷ ÷× ÷* □ ≤ ≥ ≠ ∧ ∨ ×:= ÷:= ÷×:= ÷*:= %×:= :≠:}}
| {{monocode|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}}
Line 92 ⟶ 91:
|-
| [[APL (programming language)|APL]]
| {{monocode|1=+ - × ÷ ⌈ ⌊ * ⍟ <nowiki>|</nowiki> ! ○ ~ ∨ ∧ ⍱ ⍲ &lt; ≤ = ≥ > ≠ . @ ≡ ≢ ⍴ , ⍪ ⍳ ↑ ↓ ? ⍒ ⍋ ⍉ ⌽ ⊖ ∊ ⊥ ⊤ ⍎ ⍕ ⌹ ⊂ ⊃ ∪ ∩ ⍷ ⌷ ∘ → ← / ⌿ \ ⍀ ¨ ⍣ & ⍨ ⌶ ⊆ ⊣ ⊢ ⍠ ⍤ ⌸ ⌺ ⍸}}
| (alphanumeric symbols need a ⎕ prefix)
| {{Yes}} <small>(first-order functions only)</small>
Line 104 ⟶ 103:
|-
|[[B (programming language)|B]]
|{{monocode|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}}</ref>
|
|{{Yes}}
Line 116 ⟶ 115:
|-
| [[C (programming language)|C]]
| {{monocode|1=() [] -> . ! ~ ++ -- + - * & / % << >> < <= > >= == != ^ <nowiki>|</nowiki> && <nowiki>||</nowiki> [[?:]] = += -= *= /= %= &= ^= |= <<= >>=}}
| {{mono|<code>[[sizeof]]}}</code>
| {{Yes}}
| {{Yes}}
Line 129 ⟶ 128:
| [[C++]]
| (same as C)
| (same as C plus) {{mono|<code>[[typeid]] [[new (C++)|new]] [[delete (C++)|delete]] [[Exception handling|throw]] [[decltype]] [[static_cast]] [[dynamic cast]] [[reinterpret_cast]] [[const_cast]]}}</code>
| {{Yes}}
| {{Yes}}
Line 140 ⟶ 139:
|-
| [[C sharp (programming language)|C#]]
| (same as C plus) {{mono|<code>[[?.]] ?[] [[Null coalescing operator|??]] <nowiki>??=</nowiki>}}</code>
| {{mono|1=<code>[[sizeof]] nameof new stackalloc await [[Exception handling|throw]] checked unchecked is as delegate default true false}}</code> <br /> ('''[[LINQ]]):''' {{mono|1=<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):''' {{mono|1=<code>__makeref __refvalue __reftype}}</code>
| {{Yes}}
| {{Yes}}
Line 153 ⟶ 152:
| [[Java (programming language)|Java]]
| (same as C)
| <code>[[Java syntax#Instantiation|new]] [[Exception handling|throw]] [[instanceof]]</code>
| {{Yes}}
| {{Yes}}
Line 164 ⟶ 163:
|-
| [[Eiffel (programming language)|Eiffel]]
| {{mono|1=<code>[] + - * / // = /= }}</code>
| {{mono|1=<code>not and or implies "and then" "or else" }}</code>
| {{Yes}}
| {{Yes}}
Line 176 ⟶ 175:
|-
| [[Haskell]]
| {{mono|1=<code>+ - * / ^ ^^ ** == /= > < >= <= && <nowiki>||</nowiki> >>= >> $ $! . ++ !! :}}</code> <small>Many(and moremany in common librariesmore)</small>
| (function name must be in backticks)
| {{Yes}}
Line 187 ⟶ 186:
|-
| [[Pascal (programming language)|Pascal]]
| {{mono|1=<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}}
Line 199 ⟶ 198:
|-
| [[Perl]]
| {{mono|1=<code>-> ++ -- ** ! ~ \ + - . =~ !~ * / % < > <= >= == != <=> ~~ & <nowiki>|</nowiki> ^ &amp;&amp; <nowiki>||</nowiki> ' ''{{Not a typo| // .. ... ?: = += -= *= , =>}} }}</code>
| {{mono|1=<code>print sort chmod chdir rand and or not xor lt gt le ge eq ne cmp x }}</code>
| {{Yes}}
| {{Yes}}
Line 211 ⟶ 210:
|-
| [[PHP]]
| {{mono|1=<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>
| {{mono|1=<code>clone new unset print echo isset [[instanceof]] [[Logical conjunction|and]] [[Logical disjunction|or]] [[xor]]}}</code>
| {{Yes}}
| {{Yes}}
Line 223 ⟶ 222:
|-
| [[PL/I]]
| {{mono|1=<code>( ) -> + - * / ** > ¬> >= = ¬= <= < ¬< ¬ <nowiki>&</nowiki> <nowiki>|</nowiki> <nowiki>||</nowiki>}}</code>
|
| {{Yes}}
Line 235 ⟶ 234:
|-
| [[Prolog]]
| {{mono|1=<code>:- ?- ; , . =.. = \= < =< >= > == \== - + / *}}</code>
| {{mono|1=<code>spy nospy not is mod}}</code>
| {{Yes}}
| {{Yes}}
Line 247 ⟶ 246:
|-
| [[Raku (programming language)|Raku]]
| {{mono|1=<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>
| {{mono|1=<code>print sort chmod chdir rand and or not xor lt gt le ge eq ne leg cmp x xx}}</code>
| {{Yes}}
| {{Yes}}
Line 259 ⟶ 258:
|-
| [[Seed7]]
| {{mono|1=<code>{} [] -> ** ! + - * / << >> & >< <nowiki>|</nowiki> = <> > >= < <= <& := +:= -:= *:= /:= <<:= >>:= &:= @:=}}</code>
| {{mono|1=<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}}
Line 271 ⟶ 270:
|-
| [[Smalltalk]]
| (yes - Upup 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}}
Line 283 ⟶ 282:
|-
| [[Swift (programming language)|Swift]]
| (any Unicode symbol string except) {{mono|1=<code>.}}</code> (including) {{mono|1=<code>! ~ + - * / % =+ =- =* =/ =% &+ &- &* =&+ =&- =&* && <nowiki>||</nowiki> << >> & <nowiki>|</nowiki> ^ == != < <= > >= ?? ... ..<}} (in standard library)</code>
| {{mono|1=<code>is as as?}}</code>
| {{Yes}}
| {{Yes}}
Line 295 ⟶ 294:
|-
| [[Visual Basic .NET]]
| rowspan="2" | {{mono|1=<code>() . ! ?() ?. ?! + - * / \ & << >> < <= > >= ^ <> = += -= *= /= \= &= ^= <<= >>=}}</code>
| {{mono|1=<code>New Await Mod Like Is IsNot Not And AndAlso Or OrElse Xor If(...,...) If(...,...,...) GetXmlNamespace(...) GetType(...) NameOf(...) TypeOf...Is TypeOf...IsNot DirectCast(...,...) TryCast(...,...) CType(...,...) CBool(...) CByte(...) CChar(...) CDate(...) CDec(...) CDbl(...) CInt(...) CLng(...) CObj(...) CSByte(...) CShort(...) CSng(...) CStr(...) CUInt(...) CULng(...) CUShort(...)}}</code> <br /> ('''[[LINQ]]):''' {{mono|1=<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}}