Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
String literal
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Problems=== Implicit string concatenation is not required by modern compilers, which implement constant folding, and causes hard-to-spot errors due to unintentional concatenation from omitting a comma, particularly in vertical lists of strings, as in: <syntaxhighlight lang="python"> l = ['foo', 'bar' 'zork'] </syntaxhighlight> Accordingly, it is not used in most languages, and it has been proposed for deprecation from D<ref>DLang's Issue Tracking System β [https://issues.dlang.org/show_bug.cgi?id=3827 Issue 3827] - Warn against and then deprecate implicit concatenation of adjacent string literals</ref> and Python.<ref name=guidopythonideas/> However, removing the feature breaks backwards compatibility, and replacing it with a concatenation operator introduces issues of precedence β string literal concatenation occurs during lexing, prior to operator evaluation, but concatenation via an explicit operator occurs at the same time as other operators, hence precedence is an issue, potentially requiring parentheses to ensure desired evaluation order. A subtler issue is that in C and C++,<ref>[[C++11]] draft standard, {{cite web | title=Working Draft, Standard for Programming Language C++ | url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf}}, 2.14.5 String literals [lex.string], note 13, p. 28β29: "Any other concatenations are conditionally supported with implementation-defined behavior."</ref> there are different types of string literals, and concatenation of these has implementation-defined behavior, which poses a potential security risk.<ref>{{cite web|url=https://www.securecoding.cert.org/confluence/display/seccode/STR10-C.+Do+not+concatenate+different+type+of+string+literals |title=STR10-C. Do not concatenate different type of string literals - Secure Coding - CERT Secure Coding Standards |access-date=July 3, 2014 |url-status=dead |archive-url=https://web.archive.org/web/20140714135237/https://www.securecoding.cert.org/confluence/display/seccode/STR10-C.+Do+not+concatenate+different+type+of+string+literals |archive-date=July 14, 2014 }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)