早餐吃什么减肥| 上梁山是什么意思| 山什么路| 产褥期是什么意思| 头皮痒头皮屑多是什么原因| 过敏性鼻炎吃什么药能快速缓解| 招财猫是什么品种| 孩子肚脐眼下面疼是什么原因| 女性阳性是什么病| 油性皮肤适合用什么护肤品| 惴惴不安什么意思| 心季是什么原因| 急性尿路感染吃什么药| 吐黄痰是什么原因| 痛风吃什么菜比较好| 睡觉流眼泪是什么原因| 拉稀是什么原因| 盆腔炎挂什么科| 老年人头晕挂什么科| 本科是什么学历| 档次是什么意思| 什么食物对心脏有好处| 什么人容易得眩晕症| 苏轼为什么反对王安石变法| 拉肚子能喝什么| 婴儿肥是什么意思| b型血阳性是什么意思| 庶子是什么意思| 什么叫邪淫| 中心句是什么意思| 尿液发黄是什么原因| 生蒜头吃了有什么好处和坏处| 癸酉五行属什么| pv是什么意思| 属猪的守护神是什么菩萨| 孕妇oct是什么检查| 戈谢病是什么病| 日记可以写什么| 小孩尖叫是什么原因| 肝脑涂地是什么意思| 喉咙干痒吃什么药| 为什么刚吃完饭不能洗澡| 睡觉吹气是什么原因| 大力丸是什么药| 肉毒为什么怕热敷| 硕士研究生是什么意思| 猴跟什么生肖配对最好| 长孙皇后叫什么名字| 肝脑涂地是什么意思| 碉堡是什么意思啊| 步履匆匆的意思是什么| 什么的水果| perrier是什么水| 吃什么开胃| 三个手念什么| 新生儿老是打嗝是什么原因| 为什么要喝酒| 低压低是什么原因| 黄精长什么样| 徐州菜属于什么菜系| 蟑螂的天敌是什么| 木鱼花为什么会动| aspirin是什么意思| 一库一库雅蠛蝶是什么意思| 检查腰部挂什么科| 汗毛重的女人意味着什么| 嘴唇没有血色是什么原因| 誉之曰的之是什么意思| 复杂性囊肿是什么意思| 悠悠岁月什么意思| 月经很少什么原因| 什么时候情人节| 背上长白斑是什么病的症状| 阴茎长水泡是什么原因| 舌头白色的是什么原因| 防晒霜和防晒乳有什么区别| 说什么情深似海我却不敢当| 为什么要当兵| 脚趾甲变黑是什么原因| 血小板低是什么症状| 为什么长斑| 小分子肽能治什么病| 生发吃什么食物好| 儿童补锌吃什么| 春代表什么生肖| 三点水一个高念什么| crispi是什么牌子| 下午六点多是什么时辰| 一什么之什么成语| 睡美人最怕什么脑筋急转弯| 男性补肾壮阳吃什么药效果比较好| 庸俗是什么意思| 什么叫tct检查| 怀孕为什么要吃叶酸| 角化型脚气用什么药最好| 升读什么字| 退烧药吃什么| 支行行长什么级别| 六根不净是什么意思| 切诺为什么要饭前半小时吃| 脑梗是什么意思| vjc是什么品牌| 孕妇上火什么降火最快| 泰山石敢当什么意思| 武则天叫什么名字| 紫光檀是什么木| 无花果吃多了有什么坏处| 火箭军是干什么的| 左肾结石的症状是什么| 侧睡流口水是什么原因| 陈赫火锅店叫什么名字| 牛肉饺子馅配什么蔬菜好吃| jdv是什么牌子| 发热出汗是什么原因| 冷面是用什么面做的| IB是什么| 5公里25分钟什么水平| 20点是什么时辰| 偏头疼挂什么科室| 什么样的孕妇容易翻盘| 卧蚕是什么意思| 梦见父母是什么意思| adem是什么病| 顺势而为什么意思| 麻醉学学什么| 子宫内膜什么时候脱落| 梦见自己被警察抓了是什么意思| 什么人容易得甲亢| 乳腺钙化是什么意思啊| 用凝胶排出豆腐渣一样的东西是什么原因| 牙龈爱出血是什么原因| 左眼皮老是跳是什么原因| 地藏王菩萨为什么不能拜| 血压高呕吐是什么征兆| 哮喘是什么病| 妈妈a型爸爸b型孩子是什么血型| 前胸后背出汗多是什么原因| 三七草长什么样| 白头发吃什么维生素能变黑| 7月24是什么星座| 例假提前来是什么原因| 喜欢吃肉的动物是什么生肖| 镭射有什么危害| 2月28号是什么星座| 宫颈钙化灶是什么意思| 聤耳是什么意思| 湿疹涂什么药膏| 喝酸奶有什么好处| 鬼迷心窍是什么生肖| 身价是什么意思| 窝边草是什么意思| 假菌丝是什么意思| mrcp是什么检查| 跑完步喝什么水最好| 什么颜色代表水| 温碧泉适合什么年龄| 照影是什么意思| 十二生肖为什么老鼠排第一| 肠镜挂什么科| 早上起床咳嗽是什么原因| 手指爆皮是什么原因| 甲亢挂什么科| 四肢肿胀是什么原因引起的| 11月21是什么星座| 这个字念什么| 银耳和什么一起煮最好| rh阳性是什么意思| 金木水火土各代表什么| 眼干是什么原因| 气虚吃什么中成药| 女人最大的底气是什么| 心脏下边是什么器官| 乐五行属什么| 口干舌燥是什么病| 坐骨神经有什么症状| hpv阳性是什么病| 西瓜跟什么不能一起吃| 什么材质可以放微波炉加热| ricu病房是什么意思| 栀子花黄叶是什么原因| 分泌物呈褐色是什么原因| 尿液白细胞高是什么原因| 不应期是什么| 八仙过海是什么意思| 87岁属什么生肖| 荠菜长什么样| 胆结石用什么药| 白泽是什么神兽| 金鸡报晓是什么意思| 变异性哮喘咳嗽吃什么药| 什么是生殖器疱疹| 父亲b型血母亲o型血孩子什么血型| 佳字属于五行属什么| 缺钙吃什么| 有利有弊是什么意思| 欧洲为什么没有统一| npc是什么意思| rarone是什么牌子的手表| 女生喝红牛有什么影响| 什么是县级市| 唾液分泌过多是什么原因| 女的肾虚是什么原因引起的| 碱是什么意思| 6月27是什么星座| 927什么星座| 被交警开罚单不交有什么后果| 何如是什么意思| 哺乳期吃什么水果| 合影是什么意思| anca医学上是什么意思| 金牛座和什么星座最配| 怀孕尿液是什么颜色| 摩拳擦掌是什么生肖| 吃白饭是什么意思| 眼睛疼是什么原因| 水是什么生肖| 八月三号什么星座| 农历6月21日是什么星座| 现在是什么时辰| 直肠壁增厚一般是什么情况| 蛏子是什么| 减肥吃什么药| 魇是什么意思| 赛诺菲是什么药| 黄疸高吃什么药| b3维生素又叫什么| 王维是什么派诗人| 脚有酸臭味是什么原因| 椎间盘突出是什么意思| 打马赛克是什么意思| 男人腰痛吃什么药| 法国铁塔叫什么名字| 孩子总爱哭是什么原因| 东南西北五行属什么| 因特网是什么意思| 开心果是什么意思| 未时是什么时辰| 腰间盘突出是什么原因引起的| 波罗蜜是什么意思| 区人大代表是什么级别| 为什么一直口渴| 土豆不能和什么食物一起吃| 羲字五行属什么| 沙僧为什么被贬下凡间| 什么竹水果| 仙茅配什么壮阳效果好| 喝酒喝吐了用什么缓解| 精神衰弱吃什么药| 同比增长是什么意思| 阁字五行属什么| 做梦梦见剪头发是什么意思| 尽兴而归什么意思| 厌世是什么意思| 婊子是什么生肖| 什么食物蛋白质含量最高| hys是什么意思| 什么食物补锌| pa是什么单位| 马齿菜有什么功效| 生理期喝什么| 什么情况| 潴留性囊肿是什么意思| 秀五行属什么| 减脂晚上吃什么好| 百度Jump to content

魔兽下半年节日: 9月10日玩咕咕 拍卖行变舞厅

From Wikipedia, the free encyclopedia
(Redirected from Weak typing)
百度 ——上下联动形成推进妇联改革的良好局面。

In computer programming, one of the many ways that programming languages are colloquially classified is whether the language's type system makes it strongly typed or weakly typed (loosely typed). However, there is no precise technical definition of what the terms mean and different authors disagree about the implied meaning of the terms and the relative rankings of the "strength" of the type systems of mainstream programming languages.[1] For this reason, writers who wish to write unambiguously about type systems often eschew the terms "strong typing" and "weak typing" in favor of specific expressions such as "type safety".

Generally, a strongly typed language has stricter typing rules at compile time, which implies that errors are more likely to happen during compilation. Most of these rules affect variable assignment, function return values, procedure arguments and function calling. Dynamically typed languages (where type checking happens at run time) can also be strongly typed. In dynamically typed languages, values, rather than variables, have types.

A weakly typed language has looser typing rules and may produce unpredictable or even erroneous results or may perform implicit type conversion at runtime.[2] A different but related concept is latent typing.

History

[edit]

In 1974, Barbara Liskov and Stephen Zilles defined a strongly typed language as one in which "whenever an object is passed from a calling function to a called function, its type must be compatible with the type declared in the called function."[3] In 1977, K. Jackson wrote, "In a strongly typed language each data area will have a distinct type and each process will state its communication requirements in terms of these types."[4]

Definitions of "strong" or "weak"

[edit]

A number of different language design decisions have been referred to as evidence of "strong" or "weak" typing. Many of these are more accurately understood as the presence or absence of type safety, memory safety, static type-checking, or dynamic type-checking.

"Strong typing" generally refers to use of programming language types in order to both capture invariants of the code, and ensure its correctness, and definitely exclude certain classes of programming errors. Thus there are many "strong typing" disciplines used to achieve these goals.

Implicit type conversions and "type punning"

[edit]

Some programming languages make it easy to use a value of one type as if it were a value of another type. This is sometimes described as "weak typing".

For example, Aahz Maruch observes that "Coercion occurs when you have a statically typed language and you use the syntactic features of the language to force the usage of one type as if it were a different type (consider the common use of void* in C). Coercion is usually a symptom of weak typing. Conversion, on the other hand, creates a brand-new object of the appropriate type."[5]

As another example, GCC describes this as type-punning and warns that it will break strict aliasing. Thiago Macieira discusses several problems that can arise when type-punning causes the compiler to make inappropriate optimizations.[6]

There are many examples of languages that allow implicit type conversions, but in a type-safe manner. For example, both C++ and C# allow programs to define operators to convert a value from one type to another with well-defined semantics. When a C++ compiler encounters such a conversion, it treats the operation just like a function call. In contrast, converting a value to the C type void* is an unsafe operation that is invisible to the compiler.

Pointers

[edit]

Some programming languages expose pointers as if they were numeric values, and allow users to perform arithmetic on them. These languages are sometimes referred to as "weakly typed", since pointer arithmetic can be used to bypass the language's type system.

Untagged unions

[edit]

Some programming languages support untagged unions, which allow a value of one type to be viewed as if it were a value of another type.

Static type-checking

[edit]

In Luca Cardelli's article Typeful Programming,[7] a "strong type system" is described as one in which there is no possibility of an unchecked runtime type error. In other writing, the absence of unchecked run-time errors is referred to as safety or type safety; Tony Hoare's early papers call this property security.[8]

Variation across programming languages

[edit]

Some of these definitions are contradictory, others are merely conceptually independent, and still others are special cases (with additional constraints) of other, more "liberal" (less strong) definitions. Because of the wide divergence among these definitions, it is possible to defend claims about most programming languages that they are either strongly or weakly typed. For instance:

  • Java, Pascal, Ada, and C require variables to have a declared type, and support the use of explicit casts of arithmetic values to other arithmetic types. Java, C#, Ada, and Pascal are sometimes said to be more strongly typed than C, because C supports more kinds of implicit conversions, and allows pointer values to be explicitly cast while Java and Pascal do not. Java may be considered more strongly typed than Pascal as methods of evading the static type system in Java are controlled by the Java virtual machine's type system. C# and VB.NET are similar to Java in that respect, though they allow disabling of dynamic type checking by explicitly putting code segments in an "unsafe context". Pascal's type system has been described as "too strong", because the size of an array or string is part of its type, making some programming tasks very difficult. However, Delphi fixes this issue.[9][10]
  • Smalltalk, Ruby, Python, and Self are all "strongly typed" in the sense that typing errors are prevented at runtime and they do little implicit type conversion, but these languages make no use of static type checking: the compiler does not check or enforce type constraint rules. The term duck typing is now used to describe the dynamic typing paradigm used by the languages in this group.
  • The Lisp family of languages are all "strongly typed" in the sense that typing errors are prevented at runtime. Some Lisp dialects like Common Lisp or Clojure do support various forms of type declarations[11] and some compilers (CMU Common Lisp (CMUCL)[12] and related) use these declarations together with type inference to enable various optimizations and limited forms of compile time type checks.
  • Standard ML, F#, OCaml, Haskell, Go and Rust are statically type-checked, but the compiler automatically infers a precise type for most values.
  • Assembly language and Forth can be characterized as untyped. There is no type checking; it is up to the programmer to ensure that data given to functions is of the appropriate type.

See also

[edit]

References

[edit]
  1. ^ "What to know before debating type systems | Ovid [blogs.perl.org]". blogs.perl.org. Retrieved 2025-08-06.
  2. ^ "CS1130. Transition to OO programming. – Spring 2012 --self-paced version". Cornell University, Department of Computer Science. 2005. Archived from the original on 2025-08-06. Retrieved 2025-08-06.{{cite web}}: CS1 maint: bot: original URL status unknown (link)
  3. ^ Liskov, B; Zilles, S (1974). "Programming with abstract data types". ACM SIGPLAN Notices. 9 (4): 50–59. CiteSeerX 10.1.1.136.3043. doi:10.1145/942572.807045.
  4. ^ Jackson, K. (1977). "Parallel processing and modular software construction". Design and Implementation of Programming Languages. Lecture Notes in Computer Science. Vol. 54. pp. 436–443. doi:10.1007/BFb0021435. ISBN 3-540-08360-X.
  5. ^ Aahz. "Typing: Strong vs. Weak, Static vs. Dynamic". Retrieved 16 August 2015.
  6. ^ "Type-punning and strict-aliasing - Qt Blog". Qt Blog. Retrieved 18 February 2020.
  7. ^ Luca Cardelli, "Typeful programming"
  8. ^ Hoare, C. A. R. 1974. Hints on Programming Language Design. In Computer Systems Reliability, ed. C. Bunyan. Vol. 20 pp. 505–534.
  9. ^ InfoWorld. 2025-08-06. Retrieved 16 August 2015.
  10. ^ Kernighan, Brian (1981). "Why Pascal is not my favorite programming language". Archived from the original on 2025-08-06. Retrieved 2025-08-06.
  11. ^ "CLHS: Chapter 4". Retrieved 16 August 2015.
  12. ^ "CMUCL User's Manual: The Compiler". Archived from the original on 8 March 2016. Retrieved 16 August 2015.
嘴巴干苦是什么原因 波司登是什么档次 点卯是什么意思 零四年属什么 什么的手
湿气重有什么症状 司马光和司马迁是什么关系 家里的财位在什么位置 什么叫资本运作 手掌脱皮是什么原因
暖巢早衰是什么原因 小孩睡觉出很多汗是什么原因 舌苔白厚腻吃什么药 肩周炎贴什么膏药效果最好 多吃菠萝有什么好处
子子念什么 什么是护理学 石灰的主要成分是什么 什么啤酒劲最大 铁树是什么生肖
早上醒来手麻是什么原因hcv8jop8ns4r.cn 减肥期间晚上吃什么hcv7jop9ns1r.cn 有心火是什么症状hcv8jop2ns3r.cn 高氨血症是什么病hcv9jop6ns9r.cn 喝冰美式有什么好处hcv9jop7ns0r.cn
为什么眼睛有红血丝hcv9jop3ns1r.cn 胃气虚吃什么中成药hcv9jop6ns4r.cn 结婚15年是什么婚hcv9jop5ns4r.cn 小伙子是什么意思hcv9jop0ns9r.cn 晕车药什么时候吃最好hcv9jop6ns2r.cn
胆固醇高是什么意思hcv8jop5ns2r.cn 备孕前需要做什么检查hcv7jop5ns0r.cn 脑白质疏松是什么意思hcv7jop6ns5r.cn 点子是什么意思hcv7jop9ns6r.cn 胎盘可以治什么病hcv8jop2ns1r.cn
首长是什么级别hcv7jop9ns3r.cn 鸽子红鼻头喂什么药jiuxinfghf.com 什么是溺水hcv8jop5ns7r.cn 硫酸羟氯喹片治什么病fenrenren.com 否极泰来是什么生肖hcv7jop7ns4r.cn
百度