Name resolution

From Wikipedia, the free encyclopedia

In computer science, name resolution (also called name lookup) is the process of finding the entity that an identifier used in a certain context refers to.

Contents

[edit] Name resolution in computer languages

Expressions in computer languages can contain identifiers. The semantics of such expressions depend on the entities that the identifiers refer to. The algorithm that determines what an identifier in a given context refers to is part of the language definition.

The complexity of these algorithms is influenced by the sophistication of the language. For example, name resolution in assembly language usually involves only a single simple table lookup, while name resolution in C++ is extremely complicated as it involves:

  • namespaces, which make it possible for an identifier to have different meanings depending on its associated namespace;
  • scopes, which make it possible for an identifier to have different meanings at different scope levels, and which involves various scope overriding and hiding rules. At the most basic level name resolution usually attempts to find the binding in the smallest enclosing scope, so that for example local variables supersede global variables; this is called shadowing.
  • visibility rules, which determine whether identifiers from specific namespaces or scopes are visible from the current context;
  • overloading, which makes it possible for an identifier to have different meanings depending on how it is used, even in a single namespace or scope;
  • accessibility, which determines whether identifiers from an otherwise visible scope are actually accessible and participate in the name resolution process.

[edit] Static versus dynamic

In programming languages, name resolution can be performed either at compile time or at runtime. The former is called static name resolution, the latter is called dynamic name resolution.

Examples of programming languages that use static name resolution include C, C++, Java, and Pascal. Examples of programming languages that use dynamic name resolution include Lisp, Perl, Python, Tcl, PHP, and REBOL.

[edit] Name resolution in computer networks

In computer networks, name resolution is used to find a lower level address (such as an IP address) that corresponds to a given higher level address (such as a hostname). Commands that allow name resolution are: nslookup and host. See Domain Name System, OSI Model.

[edit] See also

In other languages