Name binding

Name binding

In programming languages, name binding is the association of objects (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[disambiguation needed ] 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

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

Is list 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.

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 value. 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 function 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 [1]. Specifically, if "self::$word" in the above were changed to "static::$word" as shown in the following block, 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 (2007-05-11) (html), Using early binding and late binding in Automation, "Microsoft Support and Help" at Microsoft Help,, retrieved 2009-05-11 

Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Name Binding Protocol — (NBP) ist ein Begriff aus der Informatik. Das Name Binding Protocol, oder kurz NBP, ist als Teil der AppleTalk Protokoll Suite für die Zuordnung von Geräte Namen und Diensten zu AppleTalk Adressen und AppleTalk Sockets in einem lokalen Netzwerk… …   Deutsch Wikipedia

  • Binding — bezeichnet: Binding Preis für Natur und Umweltschutz, liechtensteinischer Preis für Natur und Umweltschutz Sophie und Karl Binding Stiftung, gemeinnützige Stiftung in Basel/Schweiz Binding Waldpreis, Preis für nachhaltige Waldwirtschaft in der… …   Deutsch Wikipedia

  • Binding (computer science) — In computer science, binding is the creation of a simple reference to something that is larger and more complicated and used frequently. The simple reference can be used instead of having to repeat the larger thing. A binding is such a… …   Wikipedia

  • Binding of Isaac — For the video game by Edmund McMillen and Florian Himsl, see The Binding of Isaac (video game). The Sacrifice of Isaac by Caravaggio, in the Baroque tenebrist manner The Binding of Isaac Akedah [1] (עקדה) o …   Wikipedia

  • Binding (linguistics) — In linguistics, binding theory is any of a broad class of theories dealing with the distribution of pronominal and anaphoric elements. The idea that there should be a specialised, coherent theory dealing with this particular set of phenomena… …   Wikipedia

  • Binding — This interesting name would appear to be locational from some now lost medieval village, but in fact is either a nickname, or job descriptive. It derives from the Olde English bindan , meaning to bind, and probably refers to a person who was a… …   Surnames reference

  • Name mangling — This article is about name mangling in computer languages. For name mangling in file systems, see filename mangling. In compiler construction, name mangling (also called name decoration) is a technique used to solve various problems caused by the …   Wikipedia

  • Name resolution — Contents 1 In computer languages 1.1 Static versus dynamic 1.2 Name masking 1.3 Alpha renaming to make name resolution trivial …   Wikipedia

  • Rudolf Georg Binding — Rudolf Georg Binding, meist Rudolf G. Binding (* 13. August 1867 in Basel; † 4. August 1938 in Starnberg, Bayern) war ein deutscher Schriftsteller. Inhaltsverzeichnis 1 Leben 2 Werke 2.1 Verfilmungen …   Deutsch Wikipedia

  • Carly Binding — Infobox musical artist Name = Carly Binding |thumb Background = Birth name = Carly Binding Alias = Born = birth date and age|1978|2|2 Died = Origin = Tauranga, New Zealand Instrument = Vocals Genre = Pop Label = Associated acts = TrueBlissCarly… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”