Printer Friendly
Dictionary, Encyclopedia and Thesaurus - The Free Dictionary
1,769,955,356 visitors served.
forum mailing list For webmasters
?
New: Language forums
Dictionary/
thesaurus
Medical
dictionary
Legal
dictionary
Financial
dictionary
Acronyms
 
Idioms
Encyclopedia
Wikipedia
encyclopedia
?

Quine

   Also found in: Dictionary/thesaurus, Wikipedia 0.02 sec.
Quine
Willard van Orman. 1908--2000, US philosopher. His works include Word and Object (1960), Philosophy of Logic (1970), The Roots of Reference (1973), and The Logic of Sequences (1990)

(programming)quine - /kwi:n/ (After the logician Willard V. Quine, via Douglas Hofstadter) A program that generates a copy of its own source text as its complete output. Devising the shortest possible quine in some given programming language is a common hackish amusement.

In most interpreted languages, any constant, e.g. 42, is a quine because it "evaluates to itself". In certain Lisp dialects (e.g. Emacs Lisp), the symbols "nil" and "t" are "self-quoting", i.e. they are both a symbol and also the value of that symbol. In some dialects, the function-forming function symbol, "lambda" is self-quoting so that, when applied to some arguments, it returns itself applied to those arguments. Here is a quine in Lisp using this idea:

((lambda (x) (list x x)) (lambda (x) (list x x)))

Compare this to the lambda expression:

(\ x . x x) (\ x . x x)

which reproduces itself after one step of beta reduction. This is simply the result of applying the combinator fix to the identity function. In fact any quine can be considered as a fixed point of the language's evaluation mechanism.

We can write this in Lisp:

((lambda (x) (funcall x x)) (lambda (x) (funcall x x)))

where "funcall" applies its first argument to the rest of its arguments, but evaluation of this expression will never terminate so it cannot be called a quine.

Here is a more complex version of the above Lisp quine, which will work in Scheme and other Lisps where "lambda" is not self-quoting:

((lambda (x) (list x (list (quote quote) x))) (quote (lambda (x) (list x (list (quote quote) x)))))

It's relatively easy to write quines in other languages such as PostScript which readily handle programs as data; much harder (and thus more challenging!) in languages like C which do not. Here is a classic C quine for ASCII machines:

char*f="char*f=%c%s%c;main() printf%c"; main()printf

For excruciatingly exact quinishness, remove the interior line break. Some infamous Obfuscated C Contest entries have been quines that reproduced in exotic ways.

Ken Thompson's back door involved an interesting variant of a quine - a compiler which reproduced part of itself when compiling (a version of) itself.


How to thank TFD for its existence? Tell a friend about us, add a link to this page, add the site to iGoogle, or visit webmaster's page for free fun content.
?Page tools
Printer friendly
Cite / link
Email
Feedback
? Mentioned in ? References in periodicals archive
 
It is important to remember that parents generally desire more, as opposed to less, information about their child, even if they are unable to articulate relevant questions (Pain, 1999; Quine & Pahl, 1986; Quine & Rutter, 1994).
A History of Western Philosophy: The Twentieth Century to Quine and Derrida.
It is hard nowadays, in the shadow of post modernity and its hermeneutics of suspicion, and in the wake of philosophers as different as Quine, Sellars, Derrida, Foucault, and Rorty, to countenance any claims to "immediate" experience as also being otherwise "innocent" or "incorrigible," not to say "universal.
 
Encyclopedia browser? ? Full browser
 
 
Encyclopedia
?

Disclaimer | Privacy policy | Feedback | Copyright © 2009 Farlex, Inc.
All content on this website, including dictionary, thesaurus, literature, geography, and other reference data is for informational purposes only. This information should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional. Terms of Use.