身上到处痒是什么原因| 什么叫情商| 血压低是什么情况| 脚抽筋吃什么药| 优思悦是什么药| 抖s什么意思| 农历十月份是什么星座| 5月3日什么星座| 如来佛祖叫什么名字| 为什么会长瘊子| 真命天子是什么生肖| 春什么秋什么的成语| 6月22什么星座| 数是什么意思| 后背疼痛挂什么科| 11月28是什么星座| 没脑子是什么意思| 金鱼藻是什么植物| 一个月没有来月经是什么原因| 1953年是什么生肖| qs是什么意思| 冰释前嫌的释是什么意思| 明天代表什么生肖| 鸟死在家里是什么征兆| ppd是什么意思| 参军是什么官职| 孩子喉咙痛吃什么药好| 辐射是什么| 喝苦荞茶有什么好处| 碘吃多了有什么危害| 买盘和卖盘是什么意思| 番茄和西红柿有什么区别| 视力sca分别代表什么| 原来是什么意思| 南京有什么好吃的| 女人在什么时候最容易怀孕| 甲状腺结节不能吃什么食物| 头皮脂溢性皮炎用什么洗发水| 心率过快吃什么药最好| 眼睛痛是什么原因| 黑蝴蝶代表什么| 什么奶粉好| 什么地响| 女人眉心有痣代表什么| 吃什么对胃好养胃的食物| 高脂血症是什么病| 西游记是什么时候写的| wear是什么意思| 梦见血是什么预兆解梦| 什么蚌相争| 女性出汗多是什么原因| mop是什么意思| 熬药用什么锅熬最好| 香芋紫是什么颜色| 蒂是什么意思| 七月十三日是什么日子| 肩周炎用什么药最好| 蚕豆是什么豆| 火龙果和香蕉榨汁有什么功效| 乌灵参是什么东西| 尿比重1.030是什么意思| im是什么意思| 心脏疼挂什么科| 什么粉一沾就痒还看不出来| 病毒感染会有什么症状| 吃什么改善睡眠| 喝水多尿多是什么原因| 什么屁股摸不得| 酸梅汤什么人不能喝| 淡紫色配什么颜色好看| 为什么筋膜炎一躺下才会疼| 萌宠是什么意思| 普洱茶适合什么季节喝| sp是什么的缩写| 肝钙化灶什么意思| 神经肌电图检查什么| 什么是钙化点| 逃出生天什么意思| 攻是什么意思| 梦见抢银行是什么意思| 1919年发生了什么| 男人遗精是什么原因造成的| 脚脖子抽筋是什么原因| 内页是什么意思| 头皮发红是什么原因| 甲状腺属于什么科| 美女指什么生肖| 康复治疗是做什么的| 一线炎是什么病严重吗| 赖是什么意思| 澳门用什么钱币| abob是什么药| 71年什么时候退休| 羊齿状结晶代表什么| 无花果什么品种最好吃| 词牌名是什么意思| aep是什么意思| 发物有什么| 手指长水泡很痒是什么原因| 贡缎是什么面料| 质子治疗是什么意思| 有心火是什么症状| 纯粹什么意思| 家里为什么会有蚂蚁| 以纯属于什么档次| 粑粑黑色是什么原因| 雌二醇是什么意思| 人类的祖先是什么| 上头了是什么意思| 官印是什么意思| 次日什么意思| 汞是什么| 5月28日什么星座| 头疼头晕挂什么科| 保家卫国是什么生肖| 尿检阴性是什么意思| 电脑长期不关机有什么影响| 东北方是什么方位| 脊髓灰质炎是什么病| 水是什么颜色| 什么操场| 什么是网球肘| 271是什么意思| 浦去掉三点水念什么| 读书与吃药是什么生肖| 结核感染是什么意思| 抖s是什么意思| 感冒了吃什么药| 子宫内膜息肉样增生是什么意思| 脚踝发黑是什么原因| 什么是蜘蛛痣| 分别心是什么意思| 刺猬是什么动物| 冬日暖阳是什么意思| 空腹吃荔枝有什么危害| pd是什么| 绿卡有什么用| 武汉属于什么地区| gi值是什么意思| 包干价是什么意思| 烈女怕缠郎是什么意思| mt是什么缩写| 什么像什么| 清洁度三度什么意思| 祖字五行属什么| 烘培是什么意思| 2月2日是什么星座| 蚕屎有什么作用和功效| 潜血是什么意思| 看见喜鹊有什么预兆| 小蛇吃什么| 痛风什么药止痛最快| 月字旁有什么字| 君无戏言什么意思| 得了幽门螺杆菌是什么症状| 亲戚是什么意思| 肚子疼吃什么药最有效| 脾胃虚寒有什么症状| 哺乳期吃辣椒对宝宝有什么影响| 扬长避短什么意思| 黑枸杞和什么一起泡水喝比较好| 心形脸适合什么发型| 总掉头发是什么原因女| 梦见骑自行车是什么意思| 中央处理器由什么组成| 毛宁和毛阿敏是什么关系| 排卵期出血有什么症状| 眼袋浮肿是什么原因| 7月4号什么星座| 老年人脚肿挂什么科| 上午8点是什么时辰| 五马分尸是什么意思| 什么是遗精| 脸上痣多是什么原因| 什么是音色| 配子是什么| c60是什么| 总头晕是什么原因| 肝ca是什么意思| 丫丫的老公叫什么| 小孩睡觉出汗是什么原因| 莲子有什么功效| 小狗需要打什么疫苗| 吃什么水果可以通便| development是什么意思| 心房扑动是什么意思| 手电筒什么牌子的好| 网贷是什么| 戍什么意思| 口羊读什么| 一个三点水一个除念什么| 做梦吃面条是什么预兆| land rover是什么车| 硒有什么功效和作用| 小寄居蟹吃什么| 菠萝蜜吃多了有什么坏处| 直视是什么意思| 治疗股癣用什么药膏| 沁是什么意思| 汗水里面有什么成分| 亦如是什么意思| 为什么做爱那么舒服| ebay是什么| 没落是什么意思| 什么症状需要做膀胱镜| 吃什么不容易怀孕| 中国国花是什么花| 梦见彩虹是什么征兆| 幼儿急疹为什么不能碰水| ml代表什么单位| 有口臭去医院挂什么科| 宵夜吃什么好| 养老金什么时候可以领取| 蜜蜂蜇人后为什么会死去| 什么是规培| 回声团是什么意思| 买手是什么职业| 个体户是什么职业| 三界是什么意思| 吃多了拉肚子是什么原因| 痰的颜色代表什么| 胆红素是什么| 肾结石是什么引起的| 什么是植物神经功能紊乱| 一颗颗什么| 婚检检查什么项目| 七月十六号是什么星座| 看演唱会需要准备什么| 爷俩是什么意思| 雪纺是什么面料| 骨穿是检查什么的| 什么时候喝牛奶效果最佳| 瘘管是什么意思| 7月17日是什么日子| 动车是什么| 老是头疼是什么原因| 蝉吃什么食物| 婴儿喝什么牌奶粉好| 学生吃什么补脑子增强记忆力最快| 尿比重是什么意思| 青蛙是什么生肖| 奶冻是什么| 俊俏什么意思| 女性肾虚吃什么药| paw是什么意思| 感冒为什么会头痛| 火韦是什么字| 睡觉盗汗是什么原因| 中出是什么意思| 塑料袋属于什么垃圾| 海菜是什么| 男人沉默了说明什么| 花甲炒什么配菜好吃| 清关是什么意思| laurel是什么牌子| 土地出让金是什么意思| 考试用什么笔| 阴道红肿是什么原因| salomon是什么牌子| 腰花是什么部位| 三个土字念什么字| 外感风寒吃什么药| 什么的东风填词语| 生粉和淀粉有什么区别| 百度

卡塔尔乒乓球公开赛资格赛:王艺迪首轮过关

(Redirected from Operator (programming))
百度   另外,刘春泉表示,也要加强消费者教育,消费者应认识到网络文化消费与传统文化消费在载体、使用期限等方面的不同。

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 (i.e. sizeof in C) or has syntax different than a function (i.e. infix addition as in a+b). 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.

Some operators are represented with symbols – characters typically not allowed for a function identifier – 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 gt, but many languages provide an infix symbolic operator so that code looks more familiar. For example, this:

if gt(x, y) then return

Can be:

if x > y then return

Some languages allow a language-defined operator to be overridden with user-defined behavior and some allow for user-defined operator symbols.

Operators may also differ semantically from functions. For example, short-circuit Boolean operations evaluate later arguments only if earlier ones are not false.

Differences from functions

edit

Syntax

edit

Many operators differ syntactically from user-defined functions. In most languages, a function is prefix notation with fixed precedence level and associativity and often with compulsory parentheses (e.g. Func(a) or (Func a) in 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,[1][2][3][4][5] and the syntax of an expression involving an operator depends on its arity (number of operands), precedence, and (if applicable), associativity. Most programming languages support binary operators and a few 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 -x, and postfix unary operators, such as post-increment x++; and binary operations are infix, such as x + y or x = y. Infix operations of higher arity require additional symbols, such as the ternary operator ?: in C, written as a ? b : c – 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 1 2 3 4 +.

Semantics

edit

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, x + y can be equivalent to a function add(x, y) in that the arguments are evaluated and then the functional behavior is applied. However, assignment is different. For example, given a = b the target a is not evaluated. Instead its value is replaced with the value of b. The scope resolution and element access operators (as in Foo::Bar and a.b, 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 operator reads the element value of an array and then assigns the element value.

++a[i];

The C++ << operator allows for fluent syntax by supporting a sequence of operators that affect a single argument. For example:

cout << "Hello" << " " << "world!" << endl;

ad hoc polymorphic

edit

Some languages provide operators that are ad hoc polymorphic – inherently overloaded. For example, in Java the + operator sums numbers or concatenates strings.

Customization

edit

Some languages support user-defined overloading (such as C++ and Fortran). An operator, defined by the language, can be 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,[6] Seed7,[7] F#, OCaml, Haskell) allow for user-defined operators. Some programming languages restrict operator symbols to special characters like + or := while others allow names like div (e.g. Pascal), and even arbitrary names (e.g. Fortran where an upto 31 character long operator name is enclosed between dots[8]).

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.

If a language does allow for defining new operators, the mechanics of doing so may involve meta-programming – specifying the operator in a separate language.

Operand coercion

edit

Some languages implicitly convert (aka coerce) operands to be compatible with each other. For example, Perl coercion rules cause 12 + "3.14" to evaluate to 15.14. The string literal "3.14" is converted to the numeric value 3.14 before addition is applied. Further, 3.14 is treated as floating point so the result is floating point even though 12 is an integer literal. JavaScript follows different rules so that the same expression evaluates to "123.14" since 12 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.

Examples

edit
Mathematical operators
Program structure operators
Conditional operators
Notable C and C++ operators

Compound operators

Operator features in programming languages

edit

The following table shows the operator features in several programming languages:

Language Symbolic operators Alphanumeric operators
Prefix
Infix
Postfix
Precedence
Associativity
Overloading
User-defined
overloading
User-defined
symbols
ALGOL 68 each symbolic operator has an alphanumeric equivalent and some a non-ASCII equivalent +* ** * / % %* %× - + &lt; &lt;= >= > = /= & -:= +:= *:= /:= %:= %*:= +=: :=: :/=:

non-ASCII: ? +× ⊥ ↑ ↓ ? ? × ÷ ÷× ÷* □ ≤ ≥ ≠ ∧ ∨ ×:= ÷:= ÷×:= ÷*:= %×:= :≠:

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 isnt Yes Yes No Yes (prefix operators always have priority 10) Infix operators are left associative, prefix operators are right associative Yes Yes Yes
APL + - × ÷ ? ? * ? | ! ○ ~ ∨ ∧ ? ? &lt; ≤ = ≥ > ≠ . @ ≡ ? ? , ? ? ↑ ↓ ? ? ? ? ? ? ? ⊥ ? ? ? ? ? ? ∪ ∩ ? ? ° → ← / ? \ ? ¨ ? & ? ? ? ? ? ? ? ? ? ? (requires ? prefix) Yes (first-order functions only) Yes Yes (higher-order functions only) Higher-order functions precede first-order functions Higher-order functions are left associative, first-order functions are right associative Yes Yes Yes (alphanumeric only)
B () [] ! ~ ++ -- + - * & / % << >> < <= > >= == != ^ | [[?:]] = =+ =- =* =/ =% =& =^ =|[9] Yes Yes Yes Yes Yes No No No
C () [] -> . ! ~ ++ -- + - * & / % << >> < <= > >= == != ^ | && || [[?:]] = += -= *= /= %= &= ^= sizeof Yes Yes Yes Yes Yes Yes No No
C++ (same as C) (same as C plus) typeid new delete throw decltype static_cast dynamic cast reinterpret_cast const_cast Yes Yes Yes Yes Yes Yes Yes No
C# (same as C plus) ?. ?[] ?? ??= sizeof nameof new stackalloc await throw checked unchecked is as delegate default true false
LINQ: from select where group...by group...by...into join...in...on...equals join...in...on...equals...into orderby orderby...descending
Roslyn-only: __makeref __refvalue __reftype
Yes Yes Yes Yes Yes Yes Yes No
Java (same as C) new throw instanceof Yes Yes Yes Yes Yes Yes No No
Eiffel [] + - * / // = /= not and or implies "and then" "or else" Yes Yes No Yes Yes No Yes Yes
Haskell + - * / ^ ^^ ** == /= > < >= <= && || >>= >> $ $! . ++ !! : (and many more) (function name must be in backticks) Yes Yes No Yes Yes Yes, using Type classes Yes
mvBasic Databasic/Unibasic + - * / ^ ** : = ! & [] += -= := # < > <= >= <> >< =< #> => #< AND OR NOT EQ NE LT GT LE GE MATCH ADDS() ANDS() CATS() DIVS() EQS() GES() GTS() IFS() Yes Yes Yes Yes Yes Yes Yes No
Pascal * / + - = < > <> <= >= := not div mod and or in Yes Yes No Yes Yes Yes No No
Perl -> ++ -- ** ! ~ \ + - . =~ !~ * / % < > <= >= == != <=> ~~ & | ^ && || ' '' // .. ... ?: = += -= *= , => print sort chmod chdir rand and or not xor lt gt le ge eq ne cmp x Yes Yes Yes Yes Yes Yes Yes No
PHP [] ** ++ -- ~ @![10] * / % + - . << >> < <= > >= == != === !== <> <=> & ^ | && || ?? ?: = += -= *= **= /= .= %= &= |= ^= <<= >>= clone new unset print echo isset instanceof and or xor Yes Yes Yes Yes Yes No No No
PL/I ( ) -> + - * / ** > ?> >= = ?= <= < ?< ? & | || Yes Yes No Yes Yes No No No
Prolog :- ?- ; , . =.. = \= < =< >= > == \== - + / * spy nospy not is mod Yes Yes Yes Yes Yes No No Yes
Raku ++ -- ** ! ~ ~~ * / + - . < > <= >= == != <=> & | ^ && || // [11] print sort chmod chdir rand and or not xor lt gt le ge eq ne leg cmp x xx Yes Yes Yes Yes Yes Yes Yes Yes[12]
Seed7 {} [] -> ** ! + - * / << >> & >< | = <> > >= < <= <& := +:= -:= *:= /:= <<:= >>:= &:= @:= conv varConv parse conj div rem mdiv mod times mult in not and or digits lpad rpad lpad0 Yes Yes Yes Yes Yes Yes Yes Yes
Smalltalk (up to two characters[13]) (alphanumeric symbols need a colon suffix) No Yes Yes No No Yes Yes Yes
Swift (any Unicode symbol string except) . (including) ! ~ + - * / % =+ =- =* =/ =% &+ &- &* =&+ =&- =&* && || << >> & | ^ == != < <= > >= ?? ... ..< is as as? Yes Yes Yes Yes (defined as partial order in precedence groups) Yes (defined as part of precedence groups) Yes Yes Yes
Visual Basic .NET () . ! ?() ?. ?! + - * / \ & << >> < <= > >= ^ <> = += -= *= /= \= &= ^= <<= >>= New Await Mod Like Is IsNot Not And AndAlso Or OrElse Xor If(...,...) If(...,...,...) GetXmlNamespace(...) GetType(...) NameOf(...) TypeOf...Is TypeOf...IsNot DirectCast(...,...) TryCast(...,...)
LINQ: From Aggregate...Into Select Distinct Where <Order By>...[Ascending|Descending] Take <Take While> Skip <Skip While> Let Group...By...Into Join...On <Group Join...On...Into>
Yes Yes Yes Yes Yes Yes Yes No

See also

edit

References

edit
  1. ^ "Operator Input Forms—Wolfram Language Documentation". reference.wolfram.com.
  2. ^ "Maxima 5.42.0 Manual: 7. Operators". maxima.sourceforge.net.
  3. ^ "Prefix, Postfix and Circumfix Operators". mythryl.org.
  4. ^ "Operators". doc.perl6.org.
  5. ^ Pribavkina; Rodaro (August 2010). State Complexity of Prefix, Suffix, Bifix and Infix Operators on Regular Languages. 14th International Conference on Developments in Language Theory. Lecture Notes in Computer Science (Conference Article). Developments in Language Theory. No. 6224. London Ontario: Springer (published 2010). pp. 376–377. doi:10.1007/978-3-642-14455-4_34. ISBN 978-3-642-14454-7. ISSN 0302-9743.
  6. ^ "SWI-Prolog -- op/3". www.swi-prolog.org.
  7. ^ "Declare an operator". seed7.sourceforge.net.
  8. ^ "Defined Operations". Intel. Retrieved 6 May 2025.
  9. ^ "A TUTORIAL INTRODUCTION TO THE LANGUAGE B".
  10. ^ "PHP: Error Control Operators - Manual". php.net.
  11. ^ "Operators". docs.perl6.org.
  12. ^ "Functions". docs.perl6.org.
  13. ^ Goldberg, Adele. "Smalltalk-80: The Language and its Implementation, p. 27, ISBN 0-201-11371-6" (PDF).
刮痧不出痧是什么原因 塔罗牌愚者是什么意思 打鼾是什么原因导致的 背水一战是什么意思 27虚岁属什么生肖
湿气重吃什么药 心脏搭桥后最怕什么 情分是什么意思 中度贫血吃什么补血最快 三尖瓣反流是什么意思
腿疼去医院挂什么科 贫血有什么危害 黄体酮低吃什么补得快 发生火灾时的正确做法是什么 什么的鸭子
势利是什么意思 泥石流是什么 可颂是什么意思 指甲凹凸不平什么原因 梦见自己吐血是什么征兆
白子画什么时候爱上花千骨的hcv8jop4ns1r.cn 什么东西越擦越小hcv8jop1ns9r.cn 口干舌燥是什么原因引起的hcv9jop0ns4r.cn 1905年属什么生肖hcv8jop9ns0r.cn 胆固醇高是什么病hcv8jop3ns3r.cn
上户口需要什么资料hcv9jop3ns0r.cn 鳄鱼吃什么食物hcv8jop6ns3r.cn nos是什么单位hcv8jop6ns4r.cn 晚上剪指甲有什么禁忌hcv8jop1ns0r.cn 每次睡觉都做梦为什么hcv9jop4ns0r.cn
中性粒细胞偏低是什么原因hcv7jop9ns6r.cn 牙龈萎缩吃什么药hcv9jop1ns7r.cn 女生有喉结是什么原因hcv8jop8ns5r.cn 唏嘘是什么意思hcv9jop2ns6r.cn 术后可以吃什么水果hcv8jop4ns9r.cn
取活检是什么意思hcv8jop6ns4r.cn 保育费是什么意思hcv8jop5ns4r.cn 眼睛充血是什么原因hcv8jop8ns5r.cn 小肠镜什么情况下需要做hcv9jop1ns6r.cn 生茶和熟茶有什么区别bysq.com
百度