Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Operator (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== 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=http://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>.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)