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:
“A comfortable house is a great source of happiness. It ranks immediately after health and a good conscience.”
—Sydney Smith (17711845)
“... the self respect of individuals ought to make them demand of their leaders conformity with an agreed-upon code of ethics and moral conduct.”
—Mary Barnett Gilson (1877?)
“A culture may be conceived as a network of beliefs and purposes in which any string in the net pulls and is pulled by the others, thus perpetually changing the configuration of the whole. If the cultural element called morals takes on a new shape, we must ask what other strings have pulled it out of line. It cannot be one solitary string, nor even the strings nearby, for the network is three-dimensional at least.”
—Jacques Barzun (b. 1907)