In a 14-year-old rec.arts.int-fiction post, @Juhana wrote:
During the slow holidays I started to think if making a quine in Inform 7 would be possible. Quine is a computer program that does nothing else but prints its own complete source code – see
Quine (computing). Turns out it is possible and here it is for your amusement: a quine for Inform 7!
I find this so overwhelmingly cool that I wanted it to see some more daylight, so I checked with Juhana that there was no objection to posting it here. Though it was written, I assume, for 5G67 or 5J39, it still compiles in 6M62 and took just a couple of very minor tweaks to make it a character-perfect quine. (Note that the source should not end with a linefeed: it should be exactly 2470 characters long.)
"Quine" by Juhana Leinonen
Quine is a room.
When play begins: say "[quine-list]".
To insta-quit: (- quit; -).
The L is a list of text that varies. The B is a list of numbers that varies. The Q is a list of numbers that varies. The S1 is a list of numbers that varies. The S2 is a list of numbers that varies.
The L is { "", "Quine", "", " by Juhana Leinonen", "", "Quine is a room.", "", "When play begins: say ", "", "", "quine-list", "", "", ".", "", "To insta-quit: (- quit; -).", "", "The L is a list of text that varies. The B is a list of numbers that varies. The Q is a list of numbers that varies. The S1 is a list of numbers that varies. The S2 is a list of numbers that varies.", "", "", "The L is { ", "", " };", "", "", "The B is { 4, 5, 6, 7, 14, 15, 16, 17, 18, 19, 22, 23, 24, 26, 27, 28, 60, 61, 62 }. The Q is { 1, 3, 10, 13, 30, 34, 36, 40, 42, 46, 48, 52, 64, 75, 77, 84 }. The S1 is { 10, 31, 37, 43, 49, 65, 68, 71, 78, 81 }. The S2 is { 12, 33, 39, 45, 51, 67, 70, 73, 80, 83 };", "", "To say quine-list:", "let c be 0; repeat with x running through L begin; ", "increase c by 1; if c is 22 begin; list-print; otherwise; say ", "", "", "x", "", "", "; if c is listed in Q, say ", "", "", "unicode 34", "", "", "; if c is listed in B, say ", "", "", "line break", "", "", "; if c is listed in S1, say ", "", "", "unicode 91", "", "", "; if c is listed in S2, say ", "", "", "unicode 93", "", "", "; end if; end repeat; insta-quit;", "", "To list-print:", "remove entry 86 from L; repeat with x running through L begin; say ", "", "", "unicode 34", "", "", "x", "", "", "unicode 34", "", ", ", "", "; end repeat; say ", "", "", "unicode 34", "", "", "unicode 34", "", "", ";", "" };
The B is { 4, 5, 6, 7, 14, 15, 16, 17, 18, 19, 22, 23, 24, 26, 27, 28, 60, 61, 62 }. The Q is { 1, 3, 10, 13, 30, 34, 36, 40, 42, 46, 48, 52, 64, 75, 77, 84 }. The S1 is { 10, 31, 37, 43, 49, 65, 68, 71, 78, 81 }. The S2 is { 12, 33, 39, 45, 51, 67, 70, 73, 80, 83 };
To say quine-list:
let c be 0; repeat with x running through L begin; increase c by 1; if c is 22 begin; list-print; otherwise; say "[x]"; if c is listed in Q, say "[unicode 34]"; if c is listed in B, say "[line break]"; if c is listed in S1, say "[unicode 91]"; if c is listed in S2, say unicode 93; end if; end repeat; insta-quit;
To list-print:
remove entry 86 from L; repeat with x running through L begin; say "[unicode 34][x][unicode 34], "; end repeat; say "[unicode 34][unicode 34]";