Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Name binding

From Wikipedia, the free encyclopedia
Association of data/code with an identifier in software
For bound variables in mathematics, seefree variables and bound variables.

Incomputer programming,name binding is the association of adata orcode entity with anidentifier.[1] An identifier bound to an entity is said toreference that entity. Amachine language has no built-in notion of identifiers, but name-entity binding as a service and notation for theprogrammer is implemented by higher-levelprogramming languages. Binding is intimately connected withscoping, as scope determines which names bind to which entities – at which locations in the program code (lexically) and in which one of the possible execution paths (temporally).

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

Rebinding and mutation

[edit]

Rebinding should not be confused with mutation or assignment.Rebinding is a change to thereferencing identifier.Assignment is a change to (the referenced) variable.Mutation is a change to an entity in memory, possibly referenced by a variable or bound to an identifier.

Consider the followingJava code:

importjava.util.LinkedList;LinkedList<String>list;// implicitly initialised to 'null'list=newLinkedList<>();list.add("foo");list=null;{LinkedList<Integer>list=newLinkedList<>();list.add(2);}

The identifierlist is bound to a variable in the first line; in the second, a linked list of strings is assigned to the variable. The linked list referenced by the variable is then mutated, adding a string to the list. Next, the variable is assigned the constantnull. In the last line, the identifier is rebound for the scope of the block. Operations within the block access a new variable and not the variable previously bound tolist.

See also

[edit]

References

[edit]
  1. ^Microsoft (May 11, 2007),Using early binding and late binding in Automation, Microsoft, retrievedMay 11, 2009
Retrieved from "https://en.wikipedia.org/w/index.php?title=Name_binding&oldid=1334175731"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp