Name Binding - Binding Time

Binding Time

The binding of names before the program is run is called static (also "early"); bindings performed as the program runs are dynamic (also "late" or "virtual").

An example of a static binding is a direct C function call: the function referenced by the identifier cannot change at runtime.

But an example of dynamic binding is dynamic dispatch, as in a C++ virtual method call. Since the specific type of a polymorphic object is not known before runtime (in general), the executed function is dynamically bound. Take, for example, the following Java code:

public void foo(java.util.List list) { list.add("bar"); }

List is an interface, so list must refer to a subtype of it. Is it a reference to a LinkedList, an ArrayList, or some other subtype of List? The actual method referenced by add is not known until runtime. In a language like C, the actual function is known.

Read more about this topic:  Name Binding

Famous quotes containing the words binding and/or time:

    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 greater part of our best years has been passed for our generation in these two great worldconvulsions. All will be changed after this war, which spends in one month more than nations earned before in years ... there is no more security in our time than in those of the Reformation or the fall of Rome.
    Stefan Zweig (18811942)