Overview of Polymorphism -多态的分类
多态有类型系统衍生。
有限类型、无限类型、确定类型。
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 -多态的分类的更多相关文章
- Objective-C中的封装、继承、多态、分类
封装的好处: 过滤不合理的值 屏蔽内部的赋值过程 让外界不必关注内部的细节 继承的好处: 不改变原来模型的基础上,拓充方法 建立了类与类之间的联系 抽取了公共代码 坏处:耦合性强(当去掉一个父类,子类 ...
- C++员工管理系统(封装+多态+继承+分类化+函数调用+读写文件+指针+升序降序算法等一系列知识结合)
1 C++职工管理系统 2 该项目实现 八个 功能 3 1-增加功能 2-显示功能 3-删除功能 4-修改功能 4 5-查找功能 6-排序功能 7-清空功能 8-退出功能 5 实现多个功能使用了多个C ...
- polymorphism多态
[概念] 方法名相同,具体操作根据类不同. eg 有open()方法的ebook, kindle 都会被打开 eg 动物叫声不同 inheritance:只有superclass subclass都有 ...
- 7.6 GRASP原则六: 多态 Polymorphism
GRASP原则六: 多态 Polymorphism How to handle alternative behaviors based on type 如何处理依据类型不同而有 不同行为的一类需求 ...
- 深入Java核心 Java中多态的实现机制(1)
在疯狂java中,多态是这样解释的: 多态:相同类型的变量,调用同一个方法时,呈现出多中不同的行为特征, 这就是多态. 加上下面的解释:(多态四小类:强制的,重载的,参数的和包含的) 同时, 还用人这 ...
- java中实现多态的机制是什么?
多态性是面向对象程序设计代码重用的一个重要机制,我们曾不只一次的提到Java多态性.在Java运行时多态性:继承和接口的实现一文中,我们曾详细介绍了Java实现运行时多态性的动态方法调度:今天我们再次 ...
- 预习笔记 多态 --S2 4.3
第三章 多态 polymorphism 多态 instance 例子override 重载 constructor 构造器ClassCastException 类型转换异常upcasting 上抛 d ...
- [.net 面向对象编程基础] (13) 面向对象三大特性——多态
[.net 面向对象编程基础] (13) 面向对象三大特性——多态 前面两节,我们了解了面向对象的的封装和继承特性,面向对象还有一大特性就是多态.比起前面的封装和继承,多态这个概念不是那么好理解.我们 ...
- PHP面向对象编程之深入理解方法重载与方法覆盖(多态)
这篇文章主要介绍了PHP面向对象编程之深入理解方法重载与方法覆盖(多态)的相关资料,需要的朋友可以参考下: 什么是多态? 多态(Polymorphism)按字面的意思就是"多种状态" ...
随机推荐
- HDU - 1403 - Longest Common Substring
先上题目: Longest Common Substring Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- GPS时间系统概述和世界时系统
6.1 GPS时间系统概述 时间包含"时刻"和"时间间隔"2个概念.所谓时刻,即发生某一现象的瞬间.在天文学和卫星定位中.与所获数据对应的时刻也称为历元.时间 ...
- Spring MVC-集成(Integration)-集成LOG4J示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_log4j.htm 说明:示例基于Spring MVC 4.1.6. 以下示例说明 ...
- JDK(Java Development Kit)内置常用自带工具一览(转)
注意:可能随着JDK的版本升级,工具也会随着增多. JDK(Java Development Kit)是Java程序员最核心的开发工具,没有之一. JDK是一个功能强大的Java开发套装,它不仅仅为我 ...
- Javascript如何实现继承?
前言 我这篇文章会误人子弟,我把继承跟构造函数实例化搞混了,汗!要想搞清楚JS的继承机制,看下大牛写的文章:http://www.cnblogs.com/dolphinX/p/3307903.html ...
- pthread2
下面我们来看看这个demo #include <stdio.h> #include <pthread.h> #include <unistd.h> #include ...
- SharePoint 2013 关闭 customErrors
在SharePoint 2013上做开发时,如果不把customErrors 关掉,那调试起来那真叫一个费劲.在2013里,关闭customErrors 和2010一样,只要把文件路径改成15目录下即 ...
- 多级联动系列——ajax调用XML实现三级联动
ajax 使用起来特别的方便,再也不操心浏览器兼容问题了.用ajax调用XML页面中的内容,来生成三级联动,OK废话不多说,跟着我一步步写吧. 首先写一个XML文件.data.xml <?xml ...
- 用HttpCombiner来减少js和css的请问次数
HttpCombiner也不记得是谁写的了,功能是把多个js文件或css文件合并到一块,压缩一下一起发给客户端来优化网站. 用法是这样的: <script type="text/jav ...
- oc25--私有变量私有方法
// // Person.h #import <Foundation/Foundation.h> @interface Person : NSObject { @public int _a ...