多态有类型系统衍生。

有限类型、无限类型、确定类型。

Classifications

Christopher Strachey (1967) introduced the concept of polymorphism informally into procedural programming languages by distinguishing functions

  • that work differently on different argument types
  • that work uniformly on a range of argument types

He defined the former as ad-hoc polymorphism and the latter as parametric polymorphism:

"Ad-Hoc polymorphism is obtained when a function works, or appears to work, on several different types (which may not exhibit a common structure) and may behave in unrelated ways for each type.  Parametric polymorphism is obtained when a function works uniformly on a range of types; these types normally exhibit some common structure." (Strachey, 1967)

Cardelli and Wegner (1985) expanded Strachey's distinction to accommodate object-oriented languages.  They distinguished functions

  • that work on a finite set of different and potentially unrelated types

    • coercion
    • overloading
  • that work on a potentially infinite number of types across some common structure
    • inclusion
    • parametric

Inclusion polymorphism is specific to object-oriented languages.

https://scs.senecac.on.ca/~oop244/pages/content/adhoc.html

Level 1 - universal vs, ad hoc polymorphism

    • functions that are universally polymorphic work uniformly for an infinite set of types
      all of which have some common structure

      • execute the same code for all admissible types
    • An ad hoc polymorphic function is just a syntactic abbreviation for small set of
      different monomorphic functions.

http://www.cs.kent.edu/~durand/CS43101Fall2004/DT-TypeSystems.html

Overview of Polymorphism -多态的分类的更多相关文章

  1. Objective-C中的封装、继承、多态、分类

    封装的好处: 过滤不合理的值 屏蔽内部的赋值过程 让外界不必关注内部的细节 继承的好处: 不改变原来模型的基础上,拓充方法 建立了类与类之间的联系 抽取了公共代码 坏处:耦合性强(当去掉一个父类,子类 ...

  2. C++员工管理系统(封装+多态+继承+分类化+函数调用+读写文件+指针+升序降序算法等一系列知识结合)

    1 C++职工管理系统 2 该项目实现 八个 功能 3 1-增加功能 2-显示功能 3-删除功能 4-修改功能 4 5-查找功能 6-排序功能 7-清空功能 8-退出功能 5 实现多个功能使用了多个C ...

  3. polymorphism多态

    [概念] 方法名相同,具体操作根据类不同. eg 有open()方法的ebook, kindle 都会被打开 eg 动物叫声不同 inheritance:只有superclass subclass都有 ...

  4. 7.6 GRASP原则六: 多态 Polymorphism

    GRASP原则六: 多态 Polymorphism  How to handle alternative behaviors based on type 如何处理依据类型不同而有 不同行为的一类需求 ...

  5. 深入Java核心 Java中多态的实现机制(1)

    在疯狂java中,多态是这样解释的: 多态:相同类型的变量,调用同一个方法时,呈现出多中不同的行为特征, 这就是多态. 加上下面的解释:(多态四小类:强制的,重载的,参数的和包含的) 同时, 还用人这 ...

  6. java中实现多态的机制是什么?

    多态性是面向对象程序设计代码重用的一个重要机制,我们曾不只一次的提到Java多态性.在Java运行时多态性:继承和接口的实现一文中,我们曾详细介绍了Java实现运行时多态性的动态方法调度:今天我们再次 ...

  7. 预习笔记 多态 --S2 4.3

    第三章 多态 polymorphism 多态 instance 例子override 重载 constructor 构造器ClassCastException 类型转换异常upcasting 上抛 d ...

  8. [.net 面向对象编程基础] (13) 面向对象三大特性——多态

    [.net 面向对象编程基础] (13) 面向对象三大特性——多态 前面两节,我们了解了面向对象的的封装和继承特性,面向对象还有一大特性就是多态.比起前面的封装和继承,多态这个概念不是那么好理解.我们 ...

  9. PHP面向对象编程之深入理解方法重载与方法覆盖(多态)

    这篇文章主要介绍了PHP面向对象编程之深入理解方法重载与方法覆盖(多态)的相关资料,需要的朋友可以参考下: 什么是多态? 多态(Polymorphism)按字面的意思就是"多种状态" ...

随机推荐

  1. ReportNG 替换testng获得测试报告

    1.导入reportng相关jar包

  2. Windows读取NXP MiFare Ultralight C类型NFC卡片的信息

    1,读取 我们需要外接一个NFC Reader让Windows可以读取NFC卡片的内容. 因为特殊原因,我们选择了Sony rc-s380 NFC Reader.相关介绍 我们需要下载并安装NFC P ...

  3. 暑假集训D15总结

    考试 日常爆炸= = T1数据背锅,回天乏力 推了两个小时的T2竟然莫名RE,我也是服了 T3考试时就没读懂题,做个鬼啊 今天一直在写某奇怪的技术贴,竟然没有写题解(手动滑稽) 希望明天不要乱炸吧 博 ...

  4. hdu_1005_Number Sequence_201310222120

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. 【ACM】NYOJ_288_Time_20130725

    Time时间限制:1000 ms  |  内存限制:65535 KB 难度:2描述 Digital clock use 4 digits to express time, each digit is ...

  6. Spring MVC-视图解析器(View Resolverr)-多重解析器(Multiple Resolver)示例(转载实践)

    以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_multiple_resolver_mapping.htm 说明:示例基于Spri ...

  7. 一个oracle bug

    最近发现一个RAC db的listener log增长特别快,于是去查看了一下. 先是查看了一下log的内容,发现都是 service_update这种内容,刷新的特别快. service_updat ...

  8. UITextView上加入默认文字

    1. 实现UITextView的代理方法 text.view.delegate = self; 2. 在UITextView上覆盖UILabel ps:必须实现 label.enabled = NO; ...

  9. hdu 3810 Magina 队列模拟0-1背包

    题意: 出一些独立的陆地,每片陆地上有非常多怪物.杀掉每一个怪物都须要一定的时间,并能获得一定的金钱.给出指定的金钱m, 求最少要多少时间能够得到m金钱,仅能选择一个陆地进行杀怪. 题解: 这题,假设 ...

  10. 计算几何 二维凸包问题 Andrew算法

    凸包:把给定点包围在内部的.面积最小的凸多边形. Andrew算法是Graham算法的变种,速度更快稳定性也更好. 首先把全部点排序.依照第一keywordx第二keywordy从小到大排序,删除反复 ...