Date: Thu, 14 Sep 89 20:29:28 -0400 To: NeWS-makers@brillig.umd.edu Subject: A PostScript Quine From: spectral!sjs@bellcore.com (Stan Switzer) "'Yields falsehood when preceded by itself in quotes" yields falsehood when preceded by itself in quotes." -- W. V. O. Quine (paraphrase) A "quine" is a program which when evaluated yields its own representation. A quine can be formally described as a fixed point of a language's denotation function. Trivial evaluations (e.g.: literals) are excluded and the program cannot require any input data (e.g.: "cat cat.c"). In my experience, the merit of a language is inversely related to the length of its shortest quine. (Though I _am_ prejudiced toward reflective semantics.) For the heck of it, let's say a PostScript quine is a procedure "{...}" which when followed by "n { exec } repeat" yields the same (or equivalent) value for any non-negative integer value of "n" (including 0). The shortest I have found for PostScript is {{[ exch /dup load /exec load ] cvx} dup exec} Compare to Lisp: ((lambda(f)(list f (list 'quote f))) '(lambda(f)(list f (list 'quote f)))) or (ASCII) C: char*f="char*f=%c%s%c;main(){printf(f,042,f,042,012);}%c";main(){printf(f,042,f,042,012);} Not that it'll change your life or anything... Enjoy, Stan Switzer sjs@bellcore.com