[swift-evolution] multi-line string literals.
Doug McKenna
doug at mathemaesthetics.com
Thu May 5 12:56:01 CDT 2016
It was not obvious reading this proposal whether comment lines or empty lines could be inserted in the middle of the multi-line string (MLS).
For instance, would the following be syntactically legal or not:
let cat = "<catalog>
/* Add as many book specs here as you want */
" <book id=\"bk101\" empty=\"\">
" <author>\(author)</author>
" </book>
// More to come
"</catalog>"
As someone who has had to write C source code that outputs boilerplate and customized code in another language, I think it should be legal to comment on the structure of a multi-line string at the most direct and appropriate spot within that string, without ill effect, as illustrated above.
What this means is that the failure to end a line with a " when that line begins with " means looking ahead not just to the next input line, but to the next non-blank (after stripping any comments and/or trailing whitespace) line that begins with a " (legal continuation of MLS), or anything else (illegal continuation of MLS).
- Doug McKenna
More information about the swift-evolution
mailing list