多态有类型系统衍生。

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

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. 【codeforces 515C】Drazil and Factorial

    [题目链接]:http://codeforces.com/contest/515/problem/C [题意] 定义f(n)=n这个数各个位置上的数的阶乘的乘积; 给你a; 让你另外求一个不含0和1的 ...

  2. [TYVJ1730]二逼平衡树

    [TYVJ1730]二逼平衡树 题目 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:1.查询k在区间内的排名2.查询区间内排名为k的值3.修改某一位值上的数值4.查 ...

  3. win7安装gmpy2

    1.下载地址:https://pypi.python.org/pypi/gmpy2 2.安装python和pip python 安装 下载: https://www.python.org/getit/ ...

  4. fzu 2128

    第一组实例 aaaa 2 aa aa 第二组 a 1 c 第三组 abcdef 2 abcd bcd 第四组 abcdef 2 abcd bcde 第五组 aaaa 2 a aa 第六组 lgcstr ...

  5. [Poj2112][USACO2003 US OPEN] Optimal Milking [网络流,最大流][Dinic+当前弧优化]

    题意:有K个挤奶机编号1~K,有C只奶牛编号(K+1)~(C+K),每个挤奶机之多能挤M头牛,现在让奶牛走到挤奶机处,求奶牛所走的最长的一条边至少是多少. 题解:从起点向挤奶机连边,容量为M,从挤奶机 ...

  6. 同开三本DJANGO,需要提升一下本职工作的能力啦

    慢慢将一些概念固化到基因内,才有可能和SPRING MVC,MEAN之类的好好作比较吧. 全都是基于1.8版本的教材,爽!!!

  7. DTrace Probes In MySQL 自定义探针

    Inserting user-defined DTrace probes into MySQL source code is very useful to help user identify the ...

  8. Clojure:将两个list合并成一个map

    假设我们有两个list,分别是: (def a [“one” “two” “three”]) (def b [1 2 3]) 我们要把它们合为一个键值对应的map,做法很简单: 1. 先将a和b合为一 ...

  9. linux下华为HSPA模块MU609的驱动问题

    环境: CPU: s3c2416 Linux: 3.6 模块: HUAWEI MU609 SIM卡: 移动3G卡.移动4G卡 首先,拿到MU609模块后,第一要做的是对模块进行一些熟悉与了解,那么资料 ...

  10. hook 鼠标键盘消息实例分析

    1.木马控制及通信方法包含:双管道,port重用.反弹技术.Hook技术,今天重点引用介绍一下hook的使用方法,hook信息后能够将结果发送到hacker邮箱等.实现攻击的目的. 转自:http:/ ...