Identifier
|
Identifiers (IDs) are lexical tokens that name entities. The concept is analogous to that of a "name". Identifiers are used extensively in virtually all information processing systems. Naming entities makes it possible to refer to them, which is essential for any kind of processing.
Identifiers in computer languages
In computer languages, identifiers are textual tokens (also called symbols) which name language entities. In programming languages, examples of such entities are variables, types, labels, subroutines, packages, etc.
Computer languages usually place restrictions on what an identifier may look like. For example, in C++, one restriction is that identifiers must be composed of letters, digits, and underscores.
In compiled programming languages, identifiers are compile time entities. That is, at runtime the compiled program operates in terms of memory addresses and offsets, and the textual identifier tokens are no longer present or used.
In interpreted languages identifiers often are available at runtime, sometimes even as first-class objects which can be freely manipulated and evaluated.
Compilers and interpreters usually do not attach meaning to the actual identifier chosen for an entity, as long as it is unique within a certain context. However, there are exceptions. For example:
- in Ruby a variable is automatically considered immutable if its identifier starts with a capital letter;
- in Fortran, the first letter in a variable's name indicates whether by default it is created as an integer or floating point variable.
See also
- keywords (reserved identifiers with special meaning)
- overloading
- naming conventions (programming)
- name binding