On 27.04.2016 17:33, Brent Royal-Gordon wrote:
Otherwise, I reject to see any reason to introduce anything new at
this area - we already can concatenate strings and place them on next
line and escape special characters.
Sure, but it's a lot less easy to understand what's going on. See the
examples in the "Motivation" and "Proposed solution" sections.


Sorry, but I don't see that your suggestion is "lot less easy to understand what's going on" in compare to what we have now.

We have :

let xml = "<?xml version=\"1.0\"?>\n" +
          "<catalog>\n" +
          " <book id=\"bk101\" empty=\"\">\n" +
          "     <author>\(author)</author>\n" +
          " </book>\n" +
          "</catalog>"

You suggest :

let xml = "<?xml version=\"1.0\"?>
          "<catalog>
          " <book id=\"bk101\" empty=\"\">
          "     <author>\(author)</author>
          " </book>
          "</catalog>"

I can't feel this like much more better because of the same escaping of special chars. I don't see much problems in \n" and + in first(current) variant. I just don't understand what such kind of multiline we need for, so we want to introduce a new 'feature' in language. I don't feel such a small improvement worth to be implemented. Just my opinion, probably I'm not right.

My suggestion(one of) :

let xml = "\
"<?xml version="1.0"?>
"<catalog>
"    <book id="myid" empty="">
"        <author>myAuthor</author>
"        <title>myTitle \tutorial 1\(edition 2)</title>
"    </book>
"</catalog>
/"

Pros:
* multi-line
* text as-is(with just " at start), no escaping, all characters are allowed
* " at the start says it is a string
* begins with "\  - clearly saying it is a start of special string
* ends with /"  - clearly saying "end of the special string"
Cons(but actually this is 'by design' of the feature for text as-is):
* not able to explicitly have 'tab' symbol (was \t)
* not able to have other escaped chars like \n
* not able to have string interpolation.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to