Thompson's self-reproducing program
Alex Colvin
alexc at dartvax.UUCP
Tue Aug 28 23:10:31 AEST 1984
"What is the point of a self-duplicating program?"
Well ... For one thing, you never have to keep the source code around.
Seriously, it's mildly interesting as a bit-banging (character-banging)
challenge to those who don't worry about the fixed-point combinator.
For those who do, here's a different version in SCHEME (or, with slight
syntax changes, in LISP).
(labels (f (lambda () f)) f)
This one simply returns itself -- not necessarily its source code. It gets
printed by the read-eval-print loop. A C analogue is
f() { return f; };
More information about the Comp.sources.unix
mailing list