Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Binding time

From Wikipedia, the free encyclopedia
(Redirected fromEarly binding)
When a binding occurs in software

Incomputer programming,binding time describes when an association is made insoftware between twodata orcode entities. This may occur either before or afterexecution starts. Early (a.k.a. static) binding occurs before the program starts running and cannot change during runtime.Late (a.k.a. dynamic or virtual) binding occurs as the program is running.[1] Binding time applies to any type of binding includingname, memory (i.e. viamalloc), and type (i.e. forliterals).

Examples

[edit]

The followingJava code demonstrates both binding times. The methodfoo is early-bound to the code block that follows the function declaration on line 3. The call toadd is late-bound sinceList is aninterface, solist must refer to asubtype of it.list may reference aLinkedList, anArrayList, or some othersubtype ofList. The method referenced byadd is not known until runtime.

importjava.util.List;publicvoidfoo(List<String>list){list.add("bar");}

Related

[edit]

Late static

[edit]

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

classA{publicstatic$word="hello";publicstaticfunctionhello(){printself::$word;}}classBextendsA{publicstatic$word="bye";}B::hello();

In this example, the PHP interpreter binds the keywordself insideA::hello() to classA, and so the call toB::hello() produces the string "hello". If the semantics ofself::$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, ifself::$word in the above were changed tostatic::$word as shown in the following block, where the keywordstatic would only be bound at runtime, then the result of the call toB::hello() would be "bye":

classA{publicstatic$word="hello";publicstaticfunctionhello(){printstatic::$word;}}classBextendsA{publicstatic$word="bye";}B::hello();

See also

[edit]

References

[edit]
  1. ^Systems and software engineering — Vocabulary ISO/IEC/IEEE 24765:2010(E), IEEE, Dec 15, 2010
  2. ^"Late Static Bindings". RetrievedJuly 3, 2013.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Binding_time&oldid=1331649111"
Category:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp