汤去掉三点水念什么| 牡丹是什么季节开的| 腺肌症有什么症状表现| 支原体吃什么药好得快| 狮子座跟什么星座最配| 腱鞘炎是什么原因引起的| 膝盖疼痛是什么原因| 基友是什么关系| 九个月的宝宝吃什么辅食食谱| 香港有什么东西值得买| 什么是网球肘| 霍金什么时候去世| 30如狼40如虎是什么意思| 海底有什么生物| 产后42天复查都检查什么| 铁棍山药有什么功效| 手心发热吃什么药最好| 什么是脂肪肝| 本心是什么意思| 127是什么意思| 贝壳吃什么| 头伏二伏三伏吃什么| 薪字五行属什么| 颈动脉强回声斑块是什么意思| 心慌吃什么药| 淋巴细胞降低说明什么| 梦见别人杀人是什么预兆| 女性什么时候最容易怀孕| 18岁属什么生肖| 大姐大是什么意思| 苦瓜不能和什么一起吃| 角瓜是什么瓜| 什么是石斛| 什么是低碳生活| 1.15是什么星座| 舌头发热是什么原因| o型血和a型血生的孩子是什么血型| 生物冰袋里面是什么| 做什么好赚钱| 6月18是什么日子| 狮子被称为什么| 牙齿遇冷热都痛是什么原因| 2005年是什么生肖| 高血压喝什么茶好| 鳞状上皮细胞是什么意思| 什么是植物人| 过敏性皮炎用什么药| 拉肚子喝什么饮料| 已知晓是什么意思| 白茶是什么茶| 先天性心脏病有什么症状| 冠心病喝什么茶最好| 南宁晚上有什么好玩的地方| 什么的晚霞| 针眼用什么眼药水| 什么鱼适合做酸菜鱼| 麻疹是什么| 再创佳绩是什么意思| 羊水偏多是什么原因| 脸颊两侧长痘痘什么原因| 蠼螋对人有什么危害| 小孩手指脱皮是什么原因| 恶露后期为什么是臭的| 遁入空门是什么意思| 疥疮是什么病| 皮可以加什么偏旁| 做什么生意| 什么房不能住人| 为什么禁止克隆人| 夏天煲什么汤好| 贻笑大方什么意思| 什么米好吃又香又软| 吃什么能提升血小板| 晚上七点是什么时辰| 小孩晚上睡觉磨牙是什么原因| 风暴是什么意思| 疝气是什么症状| 收支两条线是什么意思| 抗战纪念日为什么是9月3日| 零八年属什么| nb是什么品牌| 广义是什么意思| 瓜子脸适合什么刘海| t1是什么意思| 球菌阳性是什么意思| 新店开业送什么好| 经常感觉口渴口干是什么原因| 夏天脸上皮肤痒是什么原因| 尿痛吃什么药效果最好| 心脏属于什么组织| 娃娃亲是什么| 梦见粽子是什么预兆| 为什么会得近视眼| 什么叫道德| 明矾是什么东西| 祖字五行属什么| 榴莲什么季节成熟| 什么是无机盐| 淋巴结钙化是什么意思| 沙眼衣原体是什么| 阴差阳错代表什么生肖| 载脂蛋白a偏高是什么意思| 高锰酸钾是什么颜色| 避孕药是什么原理| 开脸是什么意思| 粗糙的什么| 女生小便带血是什么原因| 患难见真情的上一句是什么| 辐照食品什么意思| 印度是什么制度的国家| 右手麻是什么原因| 拥趸是什么意思| gia是什么意思| 空调为什么要加氟| 为什么一睡觉就做梦| 能吃是福是什么意思| 破日是什么意思| 紫气东来什么意思| 血小板是干什么用的| 银五行属性是什么| 什么叫黑户| 什么水果对眼睛好| 女人舌苔厚白吃什么药| 热疹症状该用什么药膏| 湿疹不能吃什么食物| 什么是roi| 洛阳白马寺求什么最灵| 皮肤黑的人适合穿什么颜色的衣服| 男生进入是什么感觉| 血糖高一日三餐吃什么东西最适合| 要不然是什么意思| 口且念什么| ppm是什么| 腹泻用什么药| 胃动力不足吃什么中成药| mt是什么单位| 痛风吃什么中药最有效| 普瑞巴林胶囊治什么病| 月经来吃什么好| 口干舌燥是什么原因引起的| 梦见染头发是什么意思| 皂矾是什么| 7月5日是什么星座| 金丝檀木是什么木头| 丹参滴丸治什么病| 咳嗽咳到吐是什么原因| 肝脏钙化灶什么意思| 神经过敏是什么意思| 红烧肉是什么菜系| 化验肝功挂什么科| 大姑姐最怕弟媳什么| 什么季节最短| 经常射精有什么伤害| 拉拉是什么意思| 牛的四个胃分别叫什么| 鲔鱼是什么鱼| 黑龙江有什么特产| 五月份什么星座| 器质性病变是什么意思| 农历六月初十是什么日子| 杂合变异是什么意思| balance什么意思| 大势至菩萨代表什么| 经常发低烧是什么原因| 九知道指的是什么| 什么味道| 1700年是什么朝代| 什么叫原研药| 电压高是什么原因造成| 孔子的原名叫什么| 护理员是干什么的| 什么是善良| 成都市市长是什么级别| 什么药补肾壮阳| 生生不息是什么意思| 秋天有什么植物| 蛋白粉什么时候喝效果最好| 天干是什么意思| 六月二十三号是什么星座| 梦见橘子是什么意思| 心电图是什么科室| 脚板心发热是什么原因| 升白针叫什么名字| 心乱如什么| 嘴巴里长血泡是什么原因| 中国最大的海是什么海| 日照是什么海| 舌苔发黄是什么病| 什么人靠别人的脑袋生活| 而已是什么意思| 扁平疣用什么药| 针对性是什么意思| 眼睛不能见光是什么病| 考警校需要什么条件| 角化型脚气用什么药膏| 火腿肠是什么做的| 身高别体重是什么意思| 嘴唇紫色是什么原因| 分率是什么意思| 霉菌性炎症用什么药效果最好| 反流性食管炎吃什么中药| 善哉善哉是什么意思| 奥美拉唑是什么药| 属兔适合佩戴什么饰品| 头部容易出汗是什么原因| 一带一路指的是什么| 男人吃什么药时间长| 吃生南瓜子有什么好处| 放低姿态是什么意思| 宝宝干咳吃什么药| 下线是什么意思| 西装外套配什么裤子| 寂寞的近义词是什么| romantic什么意思| 夏天喝什么解暑| 卒中患者什么意思| 蟑螂是什么样子的| 七月是什么星座| 高温天气喝什么水最好| 土字旁的字与什么有关| 男人结扎对身体有什么影响| 小腿酸什么原因| 手指关节疼痛吃什么药| 引产和流产有什么区别| 吃花生米是什么意思| 梦见手机失而复得是什么意思| 想吃肉是身体缺什么| 矢气是什么意思| 体检转氨酶高是什么原因| 希腊人是什么人种| 双非是什么意思| 声音嘶哑是什么原因| 舌强语謇是什么意思| 娇喘什么意思| 五脏六腑指的是什么| 胆汁反流吃什么药| 查乳房挂什么科| 血糖高不能吃什么食物| 黑咖啡为什么能减肥| 灵性是什么意思| 烀是什么意思| 正月初二是什么星座的| 疱疹感染是什么病| 梦见自己生了个女儿是什么预兆| 非球面镜片是什么意思| 腰困是什么原因| 梦见男朋友是什么意思| diss是什么意思| 足金是什么意思| 二个月不来月经是什么原因| 枸橼酸西地那非片有什么副作用| 疱疹不能吃什么| 神经衰弱吃什么药效果最好| 晚上吃什么不胖| 为什么会得肩周炎| 荨麻疹忌口忌什么食物| 无济于事的意思是什么| l读什么| 美国全称是什么| 白头翁是什么鸟| 帕金森病是什么原因引起的| 蹄花是什么| 塑料五行属什么| ns是什么单位| 百度Jump to content

Fútbol Cristiano Ronaldo pagará a la Hacienda espaola lo que haga falta si se le retira la petición de cárcel Spanish.xinhuanet.com

From Wikipedia, the free encyclopedia
百度 当然,消费者在算计合理性的时候,同时也要综合考虑4S店提供的置换补贴优惠,毕竟如今置换业务补贴款都超过5000元呢!细算二手车车贷当下,对二手车电商而言,最大的利润板块恐怕就是二手车金融业务:超过一半的90后年轻消费者在选购二手车时,都会考虑选择贷款二手车,殊不知,二手车贷款往往也是陷阱重重。

A structural type system (or property-based type system) is a major class of type systems in which type compatibility and equivalence are determined by the type's actual structure or definition and not by other characteristics such as its name or place of declaration. Structural systems are used to determine if types are equivalent and whether a type is a subtype of another. It contrasts with nominative systems, where comparisons are based on the names of the types or explicit declarations, and duck typing, in which only the part of the structure accessed at runtime is checked for compatibility.

Description

[edit]

In structural typing, an element is considered to be compatible with another if, for each feature within the second element's type, a corresponding and identical feature exists in the first element's type. Some languages may differ on the details, such as whether the features must match in name. This definition is not symmetric, and includes subtype compatibility. Two types are considered to be identical if each is compatible with the other.

For example, OCaml uses structural typing on methods for compatibility of object types. Go uses structural typing on methods to determine compatibility of a type with an interface. C++ template functions exhibit structural typing on type arguments. Haxe uses structural typing, but classes are not structurally subtyped.

In languages which support subtype polymorphism, a similar dichotomy can be formed based on how the subtype relationship is defined. One type is a subtype of another if and only if it contains all the features of the base type, or subtypes thereof. The subtype may contain added features, such as members not present in the base type, or stronger invariants.

A distinction exists between structural substitution for inferred and non-inferred polymorphism. Some languages, such as Haskell, do not substitute structurally in the case where an expected type is declared (i.e., not inferred), e.g., only substitute for functions that are signature-based polymorphic via type inference.[1] Then it is not possible to accidentally subtype a non-inferred type, although it may still be possible to provide an explicit conversion to a non-inferred type, which is invoked implicitly.

Structural subtyping is arguably more flexible than nominative subtyping, as it permits the creation of ad hoc types and protocols; in particular, it permits creation of a type which is a supertype of an existing type, without modifying the definition of the latter. However, this may not be desirable where the programmer wishes to create closed abstractions.

A pitfall of structural typing versus nominative typing is that two separately defined types intended for different purposes, but accidentally holding the same properties (e.g. both composed of a pair of integers), could be considered the same type by the type system, simply because they happen to have identical structure. One way this can be avoided is by creating one algebraic data type for each use.

In 1990, Cook, et al., proved that inheritance is not subtyping in structurally-typed OO languages.[2]

Checking that two types are compatible, based on structural typing, is a non-trivial operation, e.g., requires maintaining a stack of previous checked types.[3]

When a type does not match the expected structure, error messages are longer than with nominal typing.

Example

[edit]

Objects in OCaml are structurally typed by the names and types of their methods.

Objects can be created directly (immediate objects) without going through a nominative class. Classes only serve as functions for creating objects.

 # let x =
     object
       val mutable x = 5
       method get_x = x
       method set_x y = x <- y
     end;;
 val x : < get_x : int; set_x : int -> unit > = <obj>

Here the OCaml interactive runtime prints out the inferred type of the object for convenience. Its type (< get_x : int; set_x : int -> unit >) is defined only by its methods. In other words, the type of x is defined by the method types "get_x : int" and "set_x : int -> unit" rather than by any name.[4]

To define another object, which has the same methods and types of methods:

 # let y =
     object
       method get_x = 2
       method set_x y = Printf.printf "%d\n" y
     end;;
 val y : < get_x : int; set_x : int -> unit > = <obj>

OCaml considers them the same type. For example, the equality operator is typed to only take two values of the same type:

 # x = y;;
 - : bool = false

So they must be the same type, or else this wouldn't even type-check. This shows that equivalence of types is structural.

One can define a function that invokes a method:

 # let set_to_10 a = a#set_x 10;;
 val set_to_10 : < set_x : int -> 'a; .. > -> 'a = <fun>

The inferred type for the first argument (< set_x : int -> 'a; .. >) is interesting. The .. means that the first argument can be any object which has a "set_x" method, which takes an int as argument.

So it can be used on object x:

 # set_to_10 x;;
 - : unit = ()

Another object can be made that happens to have that method and method type; the other methods are irrelevant:

 # let z =
     object
       method blahblah = 2.5
       method set_x y = Printf.printf "%d\n" y
     end;;
 val z : < blahblah : float; set_x : int -> unit > = <obj>

The "set_to_10" function also works on it:

 # set_to_10 z;;
 10
 - : unit = ()

This shows that compatibility for things like method invocation is determined by structure.

Let us define a type synonym for objects with only a "get_x" method and no other methods:

 # type simpler_obj = < get_x : int >;;
 type simpler_obj = < get_x : int >

The object x is not of this type; but structurally, x is of a subtype of this type, since x contains a superset of its methods. So x can be coerced to this type:

 # (x :> simpler_obj);;
 - : simpler_obj = <obj>
 # (x :> simpler_obj)#get_x;;
 - : int = 10

But not object z, because it is not a structural subtype:

# (z :> simpler_obj);;
This expression cannot be coerced to type simpler_obj = < get_x : int >;
it has type < blahblah : float; set_x : int -> unit > but is here used with type
  < get_x : int; .. >
The first object type has no method get_x

This shows that compatibility for widening coercions are structural.

References

[edit]
  1. ^ "Signature-based polymorphism".
  2. ^ Cook, W.R.; Hill, W.L.; Canning, P.S. (January 1990). "Inheritance is not subtyping". Proceedings of the 17th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '90. San Francisco, California. pp. 125–135. doi:10.1145/96709.96721. ISBN 978-0897913430. S2CID 8225906.{{cite book}}: CS1 maint: location missing publisher (link)
  3. ^ "Type compatibility: name vs structural equivalence".
  4. ^ "Object types".
[edit]
红外线是什么 什么叫养生 复苏是什么意思 为什么心脏会隐隐作痛 秋葵长什么样
早晨起来口苦什么原因 左侧卵巢囊性结构什么意思 催乳素是什么 订盟是什么意思 03年属什么
cn是什么意思二次元 办理无犯罪记录证明需要什么材料 梦房子倒塌什么预兆 低血钾是什么原因引起的 福五行属性是什么
朗朗乾坤下一句是什么 吃什么爱放屁 糖链抗原是什么意思 c肽高说明什么 盐和醋泡脚有什么好处
梦见小蛇是什么意思yanzhenzixun.com 什么水果泡酒最好hcv9jop4ns0r.cn 头皮癣用什么药膏最好hcv9jop2ns9r.cn 月经提前十天是什么原因hcv7jop7ns1r.cn 右肩膀疼痛是什么原因hcv9jop3ns8r.cn
子宫肌瘤不能吃什么hcv8jop8ns7r.cn 尿隐血阳性是什么病zhongyiyatai.com 痞闷什么意思hcv9jop3ns0r.cn 排卵期什么时候hcv9jop4ns5r.cn iqr是什么意思hcv8jop4ns1r.cn
淼字五行属什么helloaicloud.com 虬结什么意思hcv9jop7ns5r.cn 开眼镜店需要什么设备hcv8jop9ns4r.cn gv是什么意思hcv8jop9ns0r.cn 向日葵是什么意思hcv9jop0ns2r.cn
褪黑素有什么用xinmaowt.com 立是什么生肖hcv9jop2ns3r.cn 刚生完孩子可以吃什么水果hcv8jop8ns9r.cn 五石散是什么hcv8jop8ns4r.cn 烙馍卷菜搭配什么菜hcv8jop6ns7r.cn
百度