[comp.lang.misc] Self reproducing programs

leonard@percival.UUCP (Leonard Erickson) (06/27/87)

I once mentioned self-reproducing programs to a friend. His solution was
unique. (also violated the "rules" but what the hey!)

In almost any Microsoft BASIC _interpreter_ this "program" will work:

10 LIST

:-) :-) :-)

-- 
Leonard Erickson		...!tektronix!reed!percival!leonard
CIS: [70465,203]		...!tektronix!reed!percival!!bucket!leonard
"I used to be a hacker. Now I'm a 'microcomputer specialist'.
You know... I'd rather be a hacker."

debray@arizona.edu (Saumya Debray) (06/28/87)

leonard@percival.UUCP (Leonard Erickson) writes:
> In almost any Microsoft BASIC _interpreter_ this "program" will work:
> 
> 10 LIST

The *really* trivial solution is the program consisting of the empty
string.  A "correct" compiler should compile this to produce the empty
object program, which when executed will generate the empty string as
output.

:-), naturally!
-- 
Saumya Debray		CS Department, University of Arizona, Tucson

     internet:   debray@arizona.edu
     uucp:       {allegra, cmcl2, ihnp4} !arizona!debray

ark@alice.UUCP (06/30/87)

In article <1790@megaron.arizona.edu>, debray@arizona.UUCP writes:
> The *really* trivial solution is the program consisting of the empty
> string.  A "correct" compiler should compile this to produce the empty
> object program, which when executed will generate the empty string as
> output.

This only works in some languages.  For example, the shortest
Algol 60 program is

	begin end

Fortran also prohibits empty programs, as does Cobol and many
versions of Basic.

sommar@enea.UUCP (Erland Sommarskog) (07/01/87)

In a recent article debray@arizona.edu (Saumya Debray) writes:
>The *really* trivial solution is the program consisting of the empty
>string.  A "correct" compiler should compile this to produce the empty
>object program, which when executed will generate the empty string as
>output.

Which reminds of a Pascal compiler written at the University of Copenhagen
for Univac 1100. If you forgot to give it file to compile, it answered:
"No input, blockhead. Try again, this time with a program."


-- 
Erland Sommarskog       
ENEA Data, Stockholm    
sommar@enea.UUCP