Re: PHPNuke license
On Tue, Mar 04, 2003 at 07:33:51AM -0600, John Goerzen wrote:
> On Mon, Mar 03, 2003 at 10:52:57PM -0500, Branden Robinson wrote:
> > > That sounds ludicrous and farfetched to me, given that both statements, by
> > > themselves, are already farfetched in this circumstance.
> >
> > Well, it certainly seems plausible that at least some programs can do
> > this. Consider a quine attached to a network socket.
>
> OK, I'll bite -- what's a quine?
$ dict quine
3 definitions found
[ ... ]
>From Jargon File (4.3.0, 30 APR 2001) [jargon]:
quine /kwi:n/ n. [from the name of the logician Willard van Orman
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.
(We ignore some variants of BASIC in which a program consisting of a
single empty string literal reproduces itself trivially.) Here is one
classic quine:
((lambda (x)
(list x (list (quote quote) x)))
(quote
(lambda (x)
(list x (list (quote quote) x)))))
This one works in LISP or Scheme. 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(f,34,f,34,10);}%c";
main(){printf(f,34,f,34,10);}
For excruciatingly exact quinishness, remove the interior line breaks.
Here is another elegant quine in ANSI C:
#define q(k)main(){return!puts(#k"\nq("#k")");}
q(#define q(k)main(){return!puts(#k"\nq("#k")");})
Some infamous {Obfuscated C Contest} entries have been quines that
reproduced in exotic ways. There is an amusing Quine Home Page
(http://www.nyx.org/~gthompso/quine.htm).
--
Nathan Norman - Incanus Networking mailto:nnorman@incanus.net
Whenever men attempt to suppress argument and free speech, we may
be sure that they know their cause to be a bad one.
-- R. G. Horton
Reply to: