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
Quine (computing)
(section)
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!
==="Cheating" quines=== ==== Self-evaluation ==== In many functional languages, including [[Scheme (programming language)|Scheme]] and other [[Lisp (programming language)|Lisps]], and interactive languages such as [[APL (programming language)|APL]], numbers are self-evaluating. In [[TI-BASIC]], if the last line of a program returns a value, the returned value is displayed on the screen. Therefore, in such languages a program consisting of only a single digit results in a 1-byte quine. Since such code does not ''construct'' itself, this is often considered cheating. <syntaxhighlight lang="basic"> 1 </syntaxhighlight> ==== Empty quines ==== In some languages, particularly [[scripting language]]s but also [[C (programming language)|C]], an empty source file is a fixed point of the language, being a valid program that produces no output.{{efn|1=Examples include [[Bash (Unix shell)|Bash]], [[Perl]], and [[Python (programming language)|Python]]}} Such an empty program, submitted as "the world's smallest self reproducing program", once won the "worst abuse of the rules" prize in the [[International Obfuscated C Code Contest]].<ref>{{cite web |url = http://www0.us.ioccc.org/1994/smr.hint |title = IOCCC 1994 Worst Abuse of the Rules |archive-url=https://web.archive.org/web/20201112015540/http://www0.us.ioccc.org/1994/smr.hint |archive-date=12 November 2020 |url-status=dead}}</ref> The program was not actually compiled, but used <code>cp</code> to copy the file into another file, which could be executed to print nothing.<ref>{{cite web |title=Makefile |url=http://www0.us.ioccc.org/1994/Makefile |website=IOCCC.org |access-date=4 April 2019 |archive-date=23 April 2019 |archive-url=https://web.archive.org/web/20190423002150/http://www0.us.ioccc.org/1994/Makefile |url-status=dead }}</ref> ==== Source code inspection ==== Quines, per definition, cannot receive ''any'' form of input, including reading a file, which means a quine is considered to be "cheating" if it looks at its own source code. The following [[Unix shell|shell]] script is not a quine: <syntaxhighlight lang="bash"> #!/bin/sh # Invalid quine. # Reading the executed file from disk is cheating. cat $0 </syntaxhighlight> A shorter variant, exploiting the behaviour of [[Shebang (Unix)|shebang]] directives: <syntaxhighlight lang="bash"> #!/bin/cat </syntaxhighlight> Other questionable techniques include making use of compiler messages; for example, in the [[GW-BASIC]] environment, entering "Syntax Error" will cause the interpreter to respond with "Syntax Error". Quine code can also be outputted visually, for example it's used to visualize the neutral zone in [[Yars' Revenge]], along with [[Syntactic_sugar#Syntactic_saccharin|syntactic saccharin]], to obfuscate the source code.
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)