首页 > 其他 > 详细

Overview of Polymorphism -多态的分类

时间:2018-06-07 16:51:22      阅读:161      评论:0      收藏:0      [点我收藏+]

多态有类型系统衍生。

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

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

Overview of Polymorphism -多态的分类

原文:https://www.cnblogs.com/feng9exe/p/9151549.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!