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, as 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 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 that 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.
Also, while in general terms common class method and constructor overloading is not considered polymorphism, there are more uniform languages in which classes are regular objects. In Smalltalk, for instance, classes are regular objects. In turn, this means messages sent to classes can be overloaded, and it is also possible to create objects that behave like classes without their classes inheriting from the hierarchy of classes. These are effective techniques which can be used to take advantage of Smalltalk's powerful reflection capabilities. Similar arrangements are also possible in languages such as Self and Newspeak.
Read more about this topic: Ad-hoc Polymorphism
Famous quotes containing the words late and/or binding:
“We all end up living secret lives. We create what we are willing to admire and admiring what we shouldnt confess to the secret of our own sin, our own insufficiency, our own sadness. We all end up taking our secrets into the world and handing them over to strangers, only to realize its often too late to claim them back. The very nature of time passing is sad beyond words. Memories mean theyre gone.”
—Alexander Theroux (b. 1940)
“With a binding like youve got, people are gonna want to know whats in the book.”
—Alan Jay Lerner (19181986)