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
Circular reference
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|Series of references where the last object references the first}} {{About|a series of references where the last object references the first|Multiple sources for single-source data|Circular reporting}} {{Self reference|For the Wikipedia policy in regard to reliable sources, see [[Wikipedia:Circular reference]]}} A '''circular reference''' (or '''reference cycle'''<ref name="rustrefcycle">{{cite web |last1=Klabnik |first1=Steve |last2=Nichols |first2=Carol |title=Reference Cycles Can Leak Memory |url=https://doc.rust-lang.org/book/ch15-06-reference-cycles.html |website=The Rust Programming Language |publisher=Rust Team |access-date=8 November 2023 |ref=rustrefcycle}}</ref>) is a series of [[reference]]s where the last object references the first, resulting in a closed loop. [[File:Circular Reference.svg|thumb|Circular reference (in red)]] ==Simple example== A newcomer asks a local where the town library is. "Just in front of the post office," says the local. The newcomer nods, and follows up: "But where is the post office?" "Why, that's simple," replies the local. "It's just behind the library!" ==In language== A circular reference is not to be confused with the [[logical fallacy]] of a [[circular argument]]. Although a circular reference will often be unhelpful and reveal no information, such as two entries in a book index referring to each other, it is not necessarily so that a circular reference is of no use. Dictionaries, for instance, must always ultimately be a circular reference since all words in a dictionary are defined in terms of other words, but a dictionary nevertheless remains a useful reference. Sentences containing circular references can still be meaningful: :''Her brother gave her a kitten; his sister thanked him for it.'' is circular, but not without meaning. Indeed, it can be argued that self-reference is a necessary consequence of Aristotle's [[law of non-contradiction]], a fundamental philosophical [[axiom]]. In this view, without self-reference, [[logic]] and [[mathematics]] become impossible, or at least, lack usefulness.<ref>[[Terry A. Osborn]], [https://books.google.com/books?id=fvJTwwCSy8UC&dq=%22circular+reference%22+-excel+-computer+-programming&pg=PA32 ''The future of foreign language education in the United States''], pp.31-33, Greenwood Publishing Group, 2002 {{ISBN|0-89789-719-6}}.</ref><ref name=Fiengo>Robert Fiengo, Robert May, [https://books.google.com/books?id=V77kaAVpU0UC&dq=%22circular+reference%22+-excel+-computer+-programming&pg=PA60 ''Indices and identity''], pp.59-62, MIT Press, 1994 {{ISBN|0-262-56076-3}}.</ref> ==In computer programming== {{For|circular references between objects or resources|Reference counting}} Circular references can appear in [[computer programming]] when one piece of code requires the result from another, but that code needs the result from the first. For example, the two functions, posn and plus1 in the following Python program comprise a circular reference:{{explain|date=April 2020}} <syntaxhighlight lang="python"> def posn(k: int) -> int: if k < 0: return plus1(k) return k def plus1(n: int) -> int: return posn(n + 1) </syntaxhighlight> Circular references like the above example may return valid results if they have a terminating condition. If there is no terminating condition, a circular reference leads to a condition known as [[livelock]] or [[infinite loop]], meaning it theoretically could run forever. <syntaxhighlight lang="python"> def posn(k: int) -> int: return plus1(k) def plus1(n: int) -> int: return posn(n + 1) </syntaxhighlight> In ISO Standard, SQL circular integrity constraints are implicitly supported within a single table. Between multiple tables circular constraints (e.g. foreign keys) are permitted by defining the constraints as deferrable (See [http://www.postgresql.org/docs/current/static/sql-createtable.html CREATE TABLE] for PostgreSQL and [http://docs.oracle.com/cd/B19306_01/server.102/b14200/clauses002.htm#i1015767 DEFERRABLE Constraint Examples] for Oracle). In that case the constraint is checked at the end of the transaction not at the time the DML statement is executed. To update a circular reference, two statements can be issued in a single transaction that will satisfy both references once the transaction is committed. Circular references can also happen between instances of data of a mutable type, such as in this Python script: <syntaxhighlight lang="python"> mydict = { "this": "that", "these": "those" } mydict["myself"] = mydict print(mydict) </syntaxhighlight> The {{code|lang=python|print(mydict)}} function will output {{code|lang=python|{'this': 'that', 'these': 'those', 'myself': {...}<nowiki>}</nowiki>}}, where {{code|lang=python|{...}<nowiki/>}} indicates a circular reference, in this case, to the {{code|lang=python|mydict}} dictionary. ==In spreadsheets== Circular references also occur in [[spreadsheet]]s when two cells require each other's result. For example, if the value in Cell A1 is to be obtained by adding 5 to the value in Cell B1, and the value in Cell B1 is to be obtained by adding 3 to the value in Cell A1, no values can be computed. (Even if the specifications are A1:=B1+5 and B1:=A1-5, there is still a circular reference. It does not help that, for instance, A1=3 and B1=-2 would satisfy both formulae, as there are infinitely many other possible values of A1 and B1 that can satisfy both instances.) Circular reference in worksheets can be a very useful technique for solving implicit equations such as the [[Colebrook equation]] and many others, which might otherwise require tedious [[Newton-Raphson]] algorithms in VBA or use of macros.<ref>{{cite web | title=Solve Implicit Equations Inside Your Worksheet By Anilkumar M, Dr Sreenivasan E and Dr Raghunathan K | url=http://www.frpdesigns.com/iteration.htm | access-date=2009-06-25 | archive-url=https://web.archive.org/web/20090817224237/http://www.frpdesigns.com/iteration.htm | archive-date=2009-08-17 | url-status=dead }}.</ref> A distinction should be made with processes containing a circular reference between those that are incomputable and those that are an iterative calculation with a final output. The latter may fail in spreadsheets not equipped to handle them but are nevertheless still logically valid.<ref name=Fiengo/> == See also == * {{annotated link|Causality}} * {{annotated link|Circular reporting}} * {{annotated link|Halting problem}} * {{annotated link|MS Fnd in a Lbry}} * {{annotated link|Nested function}} * {{annotated link|Quine (computing)}} * {{annotated link|Regress argument}} * {{annotated link|Self-reference}} * {{annotated link|There's a Hole in My Bucket}} ==References== {{reflist|2}} [[Category:Causal fallacies]] [[Category:Philosophical logic]] [[Category:Self-reference]]
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:About
(
edit
)
Template:Annotated link
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Explain
(
edit
)
Template:For
(
edit
)
Template:ISBN
(
edit
)
Template:Reflist
(
edit
)
Template:Self reference
(
edit
)
Template:Short description
(
edit
)