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 has lately been drawn to your correspondents attention that, at social gatherings, she is not the human magnet she would be. Indeed, it turns out that as a source of entertainment, conviviality, and good fun, she ranks somewhere between a sprig of parsley and a single ice- skate. It would appear, from the actions of the assembled guests, that she is about as hot company as a night nurse.”
—Dorothy Parker (18931967)
“Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a sock in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.”
—George Bernard Shaw (18561950)
“... looped with the creep of varying light,
Monkey-brown, fish-grey, a string of infected circles
Loitering like bullies, about to coagulate....”
—Philip Larkin (19221986)