Name Binding

In programming languages, name binding is the association of entities (data and/or code) with identifiers.[1] An identifier bound to an object is said to reference that object. Machine languages have no built-in notion of identifiers, but name-object bindings as a service and notation for the programmer is implemented by programming languages. Binding is intimately connected with scoping, as scope determines which names bind to which objects - at which locations in the program code (lexically) and in which one of the possible execution paths (temporally).

Use of an identifier id in a context that establishes a binding for id is called a binding (or defining) occurrence. In all other occurrences (e.g., in expressions, assignments, and subprogram calls), an identifier stands for what it is bound to; such occurrences are called applied occurrences.

Binding time

  • Static binding (or early binding) is name binding performed before the program is run.
  • Dynamic binding (or late binding or virtual binding) is name binding performed as the program is running.

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<String> list) {

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 C, such instance of dynamic binding may be a call to a function pointed by a variable or expression of a function pointer type whose value is unknown until it actually gets evaluated at run-time.

Rebinding and mutation

Rebinding should not be confused with mutation.

  • Rebinding is a change to the referencing identifier.
  • Mutation is a change to the referenced entity.

Consider the following Java code:

 LinkedList<String> list;
 list = new LinkedList<String>;
 list = null;

The identifier list initially references nothing (it is uninitialized); it is then rebound to reference an object (a linked list of strings). The linked list referenced by list is then mutated, adding a string to the list. Lastly, list is rebound to null.

Late static

Late static binding is a variant of binding somewhere between static and dynamic binding. Consider the following PHP example:

class A {
    static $word = "hello";
    static function hello { print self::$word; }

class B extends A {
    static $word = "bye";


In this example, the PHP interpreter binds the keyword self inside A::hello to class A, and so the call to B::hello produces the string "hello". If the semantics of self::$word had been based on late static binding, then the result would have been "bye".

Beginning with PHP version 5.3, late static binding is supported.[2] Specifically, if self::$word in the above were changed to static::$word as shown in the following block, where the keyword static would only be bound at runtime, then the result of the call to B::hello would be "bye":

class A {
    static $word = "hello";
    static function hello { print static::$word; }

class B extends A {
    static $word = "bye";


See also


  1. ^ Microsoft (May 11, 2007), Using early binding and late binding in Automation, Microsoft, retrieved 2009 
  2. ^ "Late Static Bindings". Retrieved 2013. 

  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.



Connect with defaultLogic
What We've Done
Led Digital Marketing Efforts of Top 500 e-Retailers.
Worked with Top Brands at Leading Agencies.
Successfully Managed Over $50 million in Digital Ad Spend.
Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.
Taught Advanced Internet Marketing Strategies at the graduate level.

Manage research, learning and skills at defaultLogic. Create an account using LinkedIn or facebook to manage and organize your Digital Marketing and Technology knowledge. defaultLogic works like a shopping cart for information -- helping you to save, discuss and share.

Visit defaultLogic's partner sites below: : Music Genres | Musicians | Musical Instruments | Music Industry
NCR Works : Retail Banking | Restaurant Industry | Retail Industry | Hospitality Industry

  Contact Us