夏至有什么习俗| 有什么病| 宋徽宗叫什么| 2024年属什么年| 粳米是什么米| 颠三倒四是什么意思| 附属国是什么意思| 补血补气吃什么最快最好| 广谱是什么意思| 什么是医疗器械| 尿素是什么| 排卵期什么症状和反应| 腹泻吃什么消炎药| 九门提督相当于现在什么官| 尿血是什么原因女性| 不领情是什么意思| 香水什么味道好闻| 小巧玲珑是什么意思| 霸王别姬是什么生肖| 防中暑喝什么水| 蒙古族不吃什么肉| ckd3期是什么意思| 为什么突然有狐臭了| 体育总局局长什么级别| 老凤祥银楼和老凤祥有什么区别| 手腕疼挂什么科| 传单是什么病| 右眼一直跳是什么预兆| 胆固醇高吃什么食物最好| 患难见真情的上一句是什么| 打更的人叫什么| 气泡水是什么水| 窦性心动过缓是什么意思| 常熟有什么好玩的地方| 属相兔和什么属相最佳| 吃什么养肝| 入睡难一般是什么原因造成的| camel是什么颜色| 拉稀吃什么药| 脂蛋白高是什么原因| 喝啤酒吃什么菜最好| 什么的滋味| 蟾蜍是什么动物| 鸡为什么喜欢吃泡沫| 为什么怀不上孩子| 嘴唇发紫是什么病| 211属于什么大学| 花团锦簇什么意思| 长粉刺是什么原因| 恪尽职守什么意思| 宰相的宰最早指什么| 阴部痒是什么原因| 成人打虫吃什么药| 浪子回头金不换是什么意思| 夏天适合种植什么蔬菜| 头部容易出汗是什么原因| 大红袍是什么茶类| 腰间盘膨出吃什么药效果好| 毛尖属于什么茶| 以身相许是什么意思| 菊花茶喝多了有什么坏处| 柳絮吃了有什么好处| 查处是什么意思| 7月14号是什么节日| 舍利子到底是什么| 朊病毒是什么| 合是什么生肖| 心脏早搏吃什么药最好| 女人脸色发黄吃什么补得最快| 什么叫空调病| 杨字五行属什么| 什么姿势最舒服| 什么属相好| 囫囵吞枣是什么意思| 梦到丧尸是什么预兆| 就是什么意思| 儿童长倒刺缺什么营养| 合约机什么意思| 梨状肌综合征吃什么药| 梦见女尸是什么预兆| 假性宫缩是什么感觉| 婴儿什么时候可以吃盐| 咳嗽适合吃什么水果| 外围女是什么意思| 什么是非遗| 不良于行是什么意思| 土家族是什么族| 青筋暴起是什么原因| 五行缺木是什么命| 入睡困难挂什么科| editor是什么意思| 100聚酯纤维是什么面料| AUx是什么品牌| 打边炉是什么| 凌晨3点多是什么时辰| 吃完芒果后不能吃什么食物| 妇科臭氧治疗是什么| 生化妊娠是什么原因导致的| 月经几个月不来是什么原因| 怀疑肝不好挂什么科室| 望穿秋水是什么意思| 六月二十五号是什么星座| 蛇用什么呼吸| 2月30日是什么星座| 大校军衔是什么级别| 山竹为什么那么贵| 喷字去掉口念什么| 学习机什么牌子好| shark是什么牌子| 电泳是什么| 紫色适合什么肤色的人| 肛门疼痛什么原因| 口里有异味是什么原因| 猪肉不能和什么一起吃| 什么是痉挛| 肌肉萎缩有什么症状| 儿童疝气挂什么科| 什么是碱中毒| 海兔是什么| 耐克属于什么档次| 足字旁的字和什么有关| 左前支阻滞吃什么药| 脚底长痣代表什么| 血小板计数偏高是什么原因| 做梦掉牙齿是什么意思周公解梦| 暇步士是什么档次品牌| 小便分叉是什么症状| rbp是什么意思| 脸上长斑是什么原因引起的| 指甲白色是什么原因| 狗刨坑是什么征兆| 4朵玫瑰代表什么意思| 有什么事| bbox是什么意思| 步后尘是什么意思| 什么是备皮| 撸是什么意思| 便血挂什么科室| 519是什么星座| 猫在风水上代表什么| 特别容易出汗是什么原因| ercp是什么意思| 蓝莓对身体有什么好处| 什么风大雨| acd是什么意思| 煲什么汤去湿气最好| 什么叫盗汗| 意味深长是什么意思| 头晕脑胀是什么原因| 毛的部首是什么| 甲鱼和什么不能一起吃| 子宫肌瘤吃什么药好| 七月14号是什么星座| 相亲第一次见面送什么礼物好| 为什么刚小便完又有尿意| 中暑什么症状表现| 泌乳素高是什么意思| 老人脚肿是什么原因引起的| 胸骨疼挂什么科| 双肺纹理增多增粗是什么意思| 礼成是什么意思| 复合维生素是什么| 牙龈出血吃什么药| 呼吸道感染一般用什么消炎药| 高汤是什么汤| 千里莺啼什么映什么| 葱白是什么| 梦见栽树是什么预兆| 招财猫是什么品种| 什么药护肝效果最好| 火字旁的有什么字| 湿疹是什么症状及图片| 一切有为法是什么意思| 猫的舌头为什么有刺| 尿检红细胞高是什么原因| 人缺钾有什么症状| 什么的窗户| 阴道内壁是什么样的| 墓志铭什么意思| 吃什么药可以延长时间| 血糖高早餐吃什么好| 医生属于什么编制| 阴囊潮湿什么原因| 巴厘岛机场叫什么| 飞蛾为什么会扑火| 痛风喝什么茶最好| 汗斑用什么药膏| 重孝是什么意思| 梗犬是什么意思| 命运多折 什么生肖| 曲马多是什么药| 甲方乙方是什么意思| 红枣泡水喝有什么好处| 去威海玩需要准备什么| 肩周炎贴什么膏药效果最好| 每天早上起来口苦是什么原因| 敏使朗是什么药| 嘴唇淡紫色是什么原因| 梦见杀鸡是什么意思| 脑白质脱髓鞘是什么意思| 皮肤溃烂化脓用什么药| 水什么| 女人腿肿应该检查什么| 离苦得乐什么意思| 阴阳两虚是什么症状| 女的排卵期一般是什么时间| 梦见自己流鼻血是什么预兆| 做梦梦见鬼是什么预兆| 鼠标cpi是什么意思| 减脂期吃什么| 听调不听宣什么意思| 华国锋为什么辞职| 眼睛红是什么病| 女性尿血是什么原因引起的| 肌酐高是什么意思| 久旱逢甘露是什么意思| 风流人物指什么生肖| 尿液发臭是什么原因| 金兰之交是什么意思| 净土的意思是什么| 脚气有什么症状| 导管扩张是什么意思| 没有了晨勃是什么原因| 企鹅代表什么生肖| 学什么设计最赚钱| 膝盖痛用什么药| 1975年属什么生肖| 淋巴结反应性增生是什么意思| 白细胞计数高是什么原因| 2008年出生的属什么| 私是什么意思| 汉城为什么改名叫首尔| pms是什么意思| 大宝贝是什么意思| 连城诀为什么不火| 百步穿杨是什么意思| 锑是什么| 玉米吃了有什么好处| 梦见花椒是什么意思| 4月25日是什么星座| 零申报是什么意思| 丙五行属什么| 促进钙吸收吃什么| 开是什么生肖| 三岁看小七岁看老是什么意思| 盆腔炎吃什么药好得快| 黄芪配什么不上火| 红糖荷包蛋有什么功效| 惊艳是什么意思| 左大腿外侧麻木是什么原因| 属龙本命佛是什么佛| 拉伤筋用什么药好| 拥趸是什么意思| 曹操属什么生肖| 低密度脂蛋白胆固醇偏低是什么意思| 醒酒汤是什么| 女左上眼皮跳是什么预兆| 晒伤了涂什么药| 胆囊切除有什么后遗症| 地狱不空誓不成佛是什么意思| 尿失禁用什么药好| 留守儿童是什么意思| 长江后浪推前浪是什么意思| 大便隐血弱阳性是什么意思| 百度

刚刚登陆安徽卫视和江苏卫视的电视剧《白鹿...

百度 携程旅游专家表示,这种选择大的中转站进行中转,分段购票进行换乘,火车-汽车进行联运等多种交通工具叠加使用的曲线回家方式虽然看上去有些繁琐,但对于回乡心切又抢不到票的大多数人而言不失为一种靠谱的选择。

In computer science, an operation, function or expression is said to have a side effect if it has any observable effect other than its primary effect of reading the value of its arguments and returning a value to the invoker of the operation. Example side effects include modifying a non-local variable, a static local variable or a mutable argument passed by reference; raising errors or exceptions; performing I/O; or calling other functions with side-effects.[1] In the presence of side effects, a program's behaviour may depend on history; that is, the order of evaluation matters. Understanding and debugging a function with side effects requires knowledge about the context and its possible histories.[2][3] Side effects play an important role in the design and analysis of programming languages. The degree to which side effects are used depends on the programming paradigm. For example, imperative programming is commonly used to produce side effects, to update a system's state. By contrast, declarative programming is commonly used to report on the state of system, without side effects.

Functional programming aims to minimize or eliminate side effects. The lack of side effects makes it easier to do formal verification of a program. The functional language Haskell eliminates side effects such as I/O and other stateful computations by replacing them with monadic actions.[4][5] Functional languages such as Standard ML, Scheme and Scala do not restrict side effects, but it is customary for programmers to avoid them.[6]

Effect systems extend types to keep track of effects, permitting concise notation for functions with effects, while maintaining information about the extent and nature of side effects. In particular, functions without effects correspond to pure functions.

Assembly language programmers must be aware of hidden side effects—instructions that modify parts of the processor state which are not mentioned in the instruction's mnemonic. A classic example of a hidden side effect is an arithmetic instruction that implicitly modifies condition codes (a hidden side effect) while it explicitly modifies a register (the intended effect). One potential drawback of an instruction set with hidden side effects is that, if many instructions have side effects on a single piece of state, like condition codes, then the logic required to update that state sequentially may become a performance bottleneck. The problem is particularly acute on some processors designed with pipelining (since 1990) or with out-of-order execution. Such a processor may require additional control circuitry to detect hidden side effects and stall the pipeline if the next instruction depends on the results of those effects.

Referential transparency

edit

Absence of side effects is a necessary, but not sufficient, condition for referential transparency. Referential transparency means that an expression (such as a function call) can be replaced with its value. This requires that the expression is pure, that is to say the expression must be deterministic (always give the same value for the same input) and side-effect free.

Temporal side effects

edit

Side effects caused by the time taken for an operation to execute are usually ignored when discussing side effects and referential transparency. There are some cases, such as with hardware timing or testing, where operations are inserted specifically for their temporal side effects e.g. sleep(5000) or for (int i = 0; i < 10000; ++i) {}. These instructions do not change state other than taking an amount of time to complete.

Idempotence

edit

A subroutine with side effects is idempotent if multiple applications of the subroutine have the same effect on the system state as a single application, in other words if the function from the system state space to itself associated with the subroutine is idempotent in the mathematical sense. For instance, consider the following Python program:

x = 0

def setx(n):
    global x
    x = n

setx(3)
assert x == 3
setx(3)
assert x == 3

setx is idempotent because the second application of setx to 3 has the same effect on the system state as the first application: x was already set to 3 after the first application, and it is still set to 3 after the second application.

A pure function is idempotent if it is idempotent in the mathematical sense. For instance, consider the following Python program:

def abs(n):
    return -n if n < 0 else n

assert abs(abs(-3)) == abs(-3)

abs is idempotent because the second application of abs to the return value of the first application to -3 returns the same value as the first application to -3.

Example

edit

One common demonstration of side effect behavior is that of the assignment operator in C. The assignment a = b is an expression that evaluates to the same value as the expression b, with the side effect of storing the R-value of b into the L-value of a. This allows multiple assignment:

a = (b = 3);  // b = 3 evaluates to 3, which then gets assigned to a

Because the operator right associates, this is equivalent to

a = b = 3;

This presents a potential hangup for novice programmers who may confuse

while (b == 3) {}  // tests if b evaluates to 3

with

while (b = 3) {}  // b = 3 evaluates to 3, which then casts to true so the loop is infinite

See also

edit

References

edit
  1. ^ Spuler, David A.; Sajeev, A. Sayed Muhammed (January 1994). Compiler Detection of Function Call Side Effects. James Cook University. CiteSeerX?10.1.1.70.2096. The term Side effect refers to the modification of the nonlocal environment. Generally this happens when a function (or a procedure) modifies a global variable or arguments passed by reference parameters. But here are other ways in which the nonlocal environment can be modified. We consider the following causes of side effects through a function call: 1. Performing I/O. 2. Modifying global variables. 3. Modifying local permanent variables (like static variables in C). 4. Modifying an argument passed by reference. 5. Modifying a local variable, either automatic or static, of a function higher up in the function call sequence (usually via a pointer).
  2. ^ Turner, David A., ed. (1990). Research Topics in Functional Programming. Addison-Wesley. pp.?17–42. Via Hughes, John. "Why Functional Programming Matters" (PDF). Archived (PDF) from the original on 2025-08-07. Retrieved 2025-08-07.
  3. ^ Collberg, Christian S. (2025-08-07). "CSc 520 Principles of Programming Languages". Department of Computer Science, University of Arizona. Archived from the original on 2025-08-07. Retrieved 2025-08-07.
  4. ^ "Haskell 98 report". 1998.
  5. ^ Jones, Simon Peyton; Wadler, Phil (1993). Imperative Functional Programming. Conference Record of the 20th Annual ACM Symposium on Principles of Programming Languages. pp.?71–84.
  6. ^ Felleisen, Matthias; Findler, Robert Bruce; Flatt, Matthew; Krishnamurthi, Shriram (2025-08-07). "How To Design Programs" (2?ed.). MIT Press.
前列腺炎吃什么 硌脚是什么意思 女人肝火旺吃什么好 血小板低会出现什么症状 脾胃不和吃什么中成药
448是什么意思 什么鬼大家都喜欢 检查幽门螺杆菌挂什么科 异国他乡的意思是什么 2月份是什么星座
下丘脑分泌什么激素 炎症吃什么消炎药 蹉跎是什么意思 ccc是什么意思 什么是春梦
lhc是什么意思 什么数码相机好 属虎的脖子戴什么招财 nmol是什么单位 01年属什么生肖
眼眶发青是什么原因hcv9jop4ns2r.cn 温婉是什么意思hcv7jop4ns6r.cn pacu是什么意思hcv8jop5ns5r.cn 深情款款什么意思liaochangning.com 妥了是什么意思hcv8jop2ns5r.cn
患得患失什么意思hcv8jop4ns9r.cn 纠察是什么意思hcv8jop4ns5r.cn 恶露是什么东西hcv8jop8ns5r.cn 看胰腺挂什么科beikeqingting.com 心理素质差是什么原因hcv7jop9ns9r.cn
什么食物高蛋白含量高hcv8jop4ns9r.cn 肾虚吃什么食物hcv8jop6ns7r.cn 兔子的耳朵有什么作用hcv9jop4ns8r.cn 乐意是什么意思xinjiangjialails.com 筒骨炖什么好吃hcv9jop1ns4r.cn
脚后跟疼为什么hcv9jop1ns3r.cn hb是什么意思医学inbungee.com 重度肠上皮化生是什么意思hcv9jop2ns5r.cn 6月份是什么星座的hcv7jop9ns8r.cn 白鳍豚用什么呼吸hcv9jop2ns3r.cn
百度