Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Indirection
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Computer programming construct}} {{sources|date=February 2022}} In [[computer programming]], an '''indirection''' (also called a '''reference''') is a way of referring to something using a name, reference, or container instead of the value itself. The most common form of indirection is the act of manipulating a value through its [[memory address]]. For example, accessing a [[variable (programming)|variable]] through the use of a [[pointer (computer programming)|pointer]]. A stored pointer that exists to provide a reference to an object by double indirection is called an ''indirection node''. In some older computer architectures, indirect words supported a variety of more-or-less complicated [[addressing mode]]s. Another important example is the [[domain name system]] which enables names such as <code>en.wikipedia.org</code> to be used in place of network addresses such as <code>208.80.154.224</code>. The indirection from human-readable names to network addresses means that the references to a web page become more memorable, and links do not need to change when a web site is relocated to a different server. ==Overview== A famous [[aphorism]] of [[Butler Lampson]] that is attributed to [[David Wheeler (computer scientist)|David Wheeler]] goes: "All problems in computer science can be solved by another level of indirection" (the "[[fundamental theorem of software engineering]]").<ref>{{cite book|last=Spinellis|first=Diomidis|url=http://www.dmst.aueb.gr/dds/pubs/inbook/beautiful_code/html/Spi07g.html|chapter=Another level of indirection|editor1-last=Oram|editor1-first=Andy|editor2-last=Wilson|editor2-first=Greg|title=Beautiful Code: Leading Programmers Explain How They Think|pages=279–291|publisher=O'Reilly and Associates|location=Sebastopol, California|year=2007}}</ref> This is often deliberately mis-quoted{{By whom|date=July 2024}} with "[[abstraction layer]]" substituted for "level of indirection". A [[corollary]] to this aphorism, and the original conclusion from Wheeler, is "...except for the problem of too many layers of indirection." A [[April Fools' Day Request for Comments|humorous Internet memorandum]], {{IETF RFC|1925}}, insists that: {{quote|(6) It is easier to move a problem around (for example, by moving the problem to a different part of the overall [[network architecture]]) than it is to solve it. : (6a) (corollary). It is always possible to add another level of indirection.}} [[Object-oriented programming]] makes use of indirection extensively, a simple example being [[dynamic dispatch]]. Higher-level examples of indirection are the [[design pattern (computer science)|design pattern]]s of the [[proxy pattern|proxy]] and the [[proxy server]]. [[Delegation (programming)|Delegation]] is another classic example of an indirection pattern. In [[strongly typed programming language|strongly typed]] [[interpreted language]]s with dynamic [[data type]]s, most variable references require a level of indirection: first the type of the variable is checked for safety, and then the pointer to the actual value is dereferenced and acted on. [[Recursive data type]]s are usually implemented using indirection, because otherwise if a value of a data type can contain the entirety of another value of the same data type, there is no limit to the size a value of this data type could need. When doing symbolic programming from a formal mathematical specification the use of indirection can be quite helpful. To start with a simple example the variables ''x'', ''y'' and ''z'' in an equation such as <math display="inline">z = \sqrt{ x^2 + y^2}</math> can refer to any number. One could imagine objects for various numbers and then ''x'', ''y'' and ''z'' could point to the specific numbers being used for a particular problem. The simple example has its limitation as there are infinitely many real numbers. In various other parts of symbolic programming there are only so many symbols. So to move on to a more significant example, in logic the formula ''α'' can refer to any formula, so it could be ''β'', ''γ'', ''δ'', ... or ''η''→''π'', ''ς'' ∨ ''σ'', ... When [[set-builder notation]] is employed the statement Δ={''α''} means the set of all formulae — so although the reference is to ''α'' there are two levels of indirection here, the first to the set of all ''α'' and then the second to a specific formula for each occurrence of ''α'' in the set Δ. ==See also== * [[Handle (computing)|Handle]] * [[Delegation pattern]] * [[Pointer (computer programming)|Pointer]] * [[Reference (computer science)|Reference]] * [[Dereference operator]] * [[Law of Demeter]] ==References== {{reflist}} [[Category:Data types]] [[Category:Programming constructs]] [[Category:Computing terminology]] [[Category:Unary operations]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:By whom
(
edit
)
Template:Cite book
(
edit
)
Template:IETF RFC
(
edit
)
Template:Quote
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sources
(
edit
)