Embedding Source Code in String Literals
Languages that lack flexibility in specifying string literals make it particularly cumbersome to write programming code that generates other programming code. This is particularly true when the generation language is the same or similar to the output language.
for example:
- writing code to produce quines
- generating an output language from within a web template;
- using XSLT to generate XSLT, or SQL to generate more SQL
- generating a PostScript representation of a document for printing purposes, from within a document-processing application written in C or some other language.
Nevertheless, some languages are particularly well-adapted to produce this sort of self-similar output, especially those that support multiple options for avoiding delimiter collision.
Using string literals as code that generates other code may have adverse security implications, especially if the output is based at least partially on untrusted user input. This is particularly acute in the case of Web-based applications, where malicious users can take advantage of such weaknesses to subvert the operation of the application, for example by mounting an SQL injection attack.
Read more about this topic: String Literal
Famous quotes containing the words source, code and/or string:
“It is very difficult to be wholly joyous or wholly sad on this earth. The comic, when it is human, soon takes upon itself a face of pain; and some of our griefs ... have their source in weaknesses which must be recognized with smiling compassion as the common inheritance of us all.”
—Joseph Conrad (18571924)
“Motion or change, and identity or rest, are the first and second secrets of nature: Motion and Rest. The whole code of her laws may be written on the thumbnail, or the signet of a ring.”
—Ralph Waldo Emerson (18031882)
“The Indian remarked as before, Must have hard wood to cook moose-meat, as if that were a maxim, and proceeded to get it. My companion cooked some in California fashion, winding a long string of the meat round a stick and slowly turning it in his hand before the fire. It was very good. But the Indian, not approving of the mode, or because he was not allowed to cook it his own way, would not taste it.”
—Henry David Thoreau (18171862)