Thoughts on Introspection and Copying Inspired by Mamel
utzoo!decvax!harpo!eagle!cw
utzoo!decvax!harpo!eagle!cw
Thu Nov 4 16:59:03 AEST 1982
In a recent article here, Mamel made some comments about the
difference between programs that copy and programs that
are introspective. I intended to reply to him by mail, but
(unlike the Postal Service) the mail did not go through. So
I am posting the article; I hope this explains the reason for its
odd style.
Your article does not make sense because you seem to believe that
compilation is somehow different from interpretation, either
practically or theoretically. They are simply different ends of
a spectrum. In particular, the C language defines (in some sense)
an automaton. All we care about is the C source, not how it is
executed. If it is compiled on your machine, fine; on
mine it may execute directly. But an object file is of no interest
whatsoever.
Traditionally, introspective programs have been Turing machine
programs (or programs in other very artificial computing environments).
These programs have input whether they like it or not; consider
that a Turing machine has a tape always. But for C (or Fortran or Ada
or ...), an introspective program should read no input. A friend
suggests that the only system calls allowed be output calls. Similarly,
to be a legitimate introspective program, the program must not only
pass the diff test proposed here, it must pass the test on any other
similarly configured machine, including one on which the source file
is not accessible if you are talking about compiled programs. In the
case of interpretation, this rule means that the program must work
on another interpreter, including one that throws away the source
and converts to an internal format.
Two more points. First, your shell procedure is possibly a candidate
for shell introspection, although if it looks in the file
system it probably isn't legitimate. Second, another
introspective problem is to write a string of bits (or octals or ....)
that execute directly on your machine and print themselves out.
But that is not a C problem; it is a VAX (or 70 or ....) problem.
Finally, let me make the point that the burying of the source text inside
the source text itself is exactly the point of introspection. It seems
paradoxical because you have to use the source to produce something
exactly as big as itself; thus some part of itself must be both data
and instructions.
Charles
More information about the Comp.lang.c
mailing list