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)

polymorphism

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

adhoc polymorphism

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

 

转载于:https://www.cnblogs.com/feng9exe/p/9151549.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值