Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>Overview</h3> <p>Apart from "avoid internally escaping quotes" and the examples previously provided by @tadman there are other use-cases as well:</p> <ul> <li>auto-generating code in the same language as the generator itself (e.g., Ruby generating Ruby) </li> <li>providing cleanly-formatted code that does not confuse the syntax-highlighting feature of your text editor</li> <li>allow storage of codeblocks that may have to pass through multiple storage layers (such as a database interacting with a website, or a snippets management system interacting with a text editor, which interacts with a subshell, and so forth)</li> </ul> <h3>Details</h3> <p>This approach is a general-purpose and robust idiom that works well with any kind of tool that does automated code generation, including but not limited to tools that write boilerplate code in other languages, or tools that manage code snippets for an IDE or text editor.</p> <p>Besides the examples already provided by @tadman, there is the general case of generating code where the code being generated is the same or substantially similar syntax as the code of the generating program. </p> <p>In these cases, the solution does a lot more than help with avoiding the use of backslashes to escape quotes. Without a solution like this, there are cases where the generated code can get extremely difficult to maintain. </p> <p>To see examples of this, feel free to take a look at the following references.</p> <h3>References</h3> <p>[ See e.g., </p> <ul> <li><a href="http://en.wikipedia.org/wiki/Leaning_toothpick_syndrome">http://en.wikipedia.org/wiki/Leaning_toothpick_syndrome</a></li> <li><a href="http://c2.com/cgi/wiki?QuineProgram">http://c2.com/cgi/wiki?QuineProgram</a></li> <li><a href="http://en.wikipedia.org/wiki/Delimiter#Delimiter_collision">http://en.wikipedia.org/wiki/Delimiter#Delimiter_collision</a></li> <li><a href="http://en.wikipedia.org/wiki/Quine_(computing)">http://en.wikipedia.org/wiki/Quine_(computing)</a> </li> </ul> <p>]</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload