Ad-hoc Polymorphism - Late Binding

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

Other articles related to "late binding, late":

Comparison Of C Sharp And Java - Language and Features - Late Binding
... Runtime (dynamic) binding Java C# Late-bound (dynamic) type No Yes. ...
Late Binding - Criticism
... Late binding has poorer performance than an early bound method call ... Late binding necessarily prevents the use of static type checking ... When making a late bound call, the compiler has to assume that the method exists ...

Famous quotes containing the words binding and/or late:

    What is lawful is not binding only on some and not binding on others. Lawfulness extends everywhere, through the wide-ruling air and the boundless light of the sky.
    Empedocles 484–424 B.C., Greek philosopher. The Presocratics, p. 142, ed. Philip Wheelwright, The Bobbs-Merrill Co., Inc. (1960)

    The value of old age depends upon the person who reaches it. To some men of early performance it is useless. To others, who are late to develop, it just enables them to finish the job.
    Thomas Hardy (1840–1928)