5
\$\begingroup\$

Related to this quine answer. There was this comment:

That meta question is not applicable to this answer. document.body is not a function which you've created and are now printing the source of. document.body is a function that returns an object with string attributes that contain the source code of the program. – Jo King

This comment basically says there is some abstraction between the source code and accessing it. To me, this still looks like the same thing as reading your own source code.

Should this be allowed in quines?


This is not a duplicate of What counts as a proper quine?

Even though the question is similar, there were enough likes on my questions in the comments on the JS answer that there is obviously still some clarification needed.

\$\endgroup\$
5
  • \$\begingroup\$ "document.body is a function that returns an object with string attributes that contain the source code of the program" is false at least here, maybe discuss when fixed? \$\endgroup\$
    – l4m2
    May 1, 2018 at 22:51
  • 2
    \$\begingroup\$ Possible duplicate of What counts as a proper quine? \$\endgroup\$
    – Οurous
    May 12, 2018 at 4:50
  • 1
    \$\begingroup\$ This is not a duplicate. The fact that people still didn't know if this was allowed proves that this separate question is necessary. \$\endgroup\$
    – mbomb007
    May 13, 2018 at 3:08
  • \$\begingroup\$ @mbomb007 All words here are contained there, it's another problem if you (and in fact, lots of users including me before) don't admire 4877 \$\endgroup\$
    – l4m2
    May 14, 2018 at 12:18
  • \$\begingroup\$ @l4m2 Are you serious? You're the one who thought it was allowable to use document.body. That alone is enough reason to have this question. \$\endgroup\$
    – mbomb007
    May 14, 2018 at 13:37

3 Answers 3

23
\$\begingroup\$

If someone submits a program as "C (Linux)" which opens /dev/sda1 (typically the primary disk drive) and searches for the source of the program, that is reading its own source code, even though it doesn't technically open "the" file containing it.

Extracting a JavaScript program from document.body seems to me to be a direct analogue. There's a level of indirection, but it looks like a duck and quacks like a duck. It shouldn't be considered a permissible technique in a true quine.

\$\endgroup\$
5
  • 6
    \$\begingroup\$ I agree with your answer, and I wonder why people aren't applying the quack test to this situation. Do you have any thoughts? It seems to me that the JS programs are pretty directly reading their own source code \$\endgroup\$
    – dylnan
    May 2, 2018 at 21:37
  • \$\begingroup\$ I think a line could be drawn between whether the function/attribute you're accessing was declared by you, or by the program on startup. The CJam and JS quines both create the function, then print it, while document.body is already there \$\endgroup\$
    – Jo King Mod
    May 8, 2018 at 7:17
  • \$\begingroup\$ @JoKing, to whom is that comment addressed? I'm not sure whether it's intended for dylnan or attached to the wrong post. \$\endgroup\$ May 8, 2018 at 9:48
  • \$\begingroup\$ @PeterTaylor Mostly dylnan's comment, sorry for the confusion \$\endgroup\$
    – Jo King Mod
    May 8, 2018 at 9:49
  • \$\begingroup\$ If you also count the first parsing as "reading source" then there's just no proper quine exist --- System must read the program to know what to do, so we have to allow it, making your expression only apply to document.body.innerHTML (or if more strict, if they're same) \$\endgroup\$
    – l4m2
    Nov 15 at 17:16
-1
\$\begingroup\$

It must be possible to identify a section of the program which encodes a different part of the program. ("Different" meaning that the two parts appear in different positions.)

So, these are invalid:

<img onerror="alert(document.body.innerHTML)" src="#">
<img onerror="alert(this.outerHTML)" src="#">
<body onload="alert(document.body.outerHTML.slice(0,-7))">
<div id="r"><script>setTimeout("alert(r.outerHTML)")</script></div>

It's just nothing about document.body

\$\endgroup\$
5
  • \$\begingroup\$ Yes, those are all invalid. The reason that document.body is being disallowed is that, in general, the only thing you can do with it is indirectly read the source code. \$\endgroup\$
    – Jo King Mod
    May 14, 2018 at 13:39
  • \$\begingroup\$ You've only copied the first half of the definition. The second half says Furthermore, a quine must not access its own source, directly or indirectly. \$\endgroup\$
    – Jo King Mod
    May 14, 2018 at 21:21
  • \$\begingroup\$ @JoKing True. but with the definition before, the "access own source" seems only point to file operation \$\endgroup\$
    – l4m2
    May 15, 2018 at 1:20
  • \$\begingroup\$ Nope. See SMBF quines, Befunge/><>'s get command, Del|m|t. Generally, if you didn't create the representation of the source, you're not allowed to access it. \$\endgroup\$
    – Jo King Mod
    May 15, 2018 at 2:07
  • \$\begingroup\$ @JoKing Also if you claim document.body is a function that returns an object with string attributes that contain the source code of the program why don't you say (global) is an object with sub attributes that contain the source code of the program? \$\endgroup\$
    – l4m2
    Jun 24, 2019 at 8:27
-5
\$\begingroup\$

In the situation the link point, document.body.innerText don't point to the source code at all

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .