Ad hoc polymorphism: Difference between revisions

Content deleted Content added
real link to "subtyping polymorphism"
real link to "subtyping polymorphism"
Line 14:
== Late binding ==
 
The previous section notwithstanding, there are other ways in which ad-hoc polymorphism can work out. Consider for example the Smalltalk language. In [[Smalltalk]], the overloading is done at run time because the methods ("function implementation") for each overloaded message ("overloaded function") are resolved when they are about to be executed. This happens at run time, after the program is compiled. Therefore, polymorphism is given by [[#Subtyping polymorphism|subtyping polymorphism]] as in other languages, and it is also extended in functionality by ad-hoc polymorphism at run time.
 
A closer look will also reveal that Smalltalk provides a slightly different variety of ad-hoc polymorphism. Since Smalltalk has a late bound execution model, and since it provides objects the ability to handle messages which are not understood, it is possible to go ahead and implement functionality using polymorphism without explicitly overloading a particular message. This may not be generally recommended practice for everyday programming, but it can be quite useful when implementing proxies.