> On Apr 11, 2017, at 4:52 PM, Ricardo Parada via swift-evolution
> <[email protected]> wrote:
>
> I think the enabling of the indentation stripping could be relaxed a little
> bit and not require the opening delimiter to end its line. So for example,
> it would be possible to do this:
>
>
> let xml = """<?xml version="1.0"?>
> <catalog>
> <book id="bk101" empty="">
> <author>\(author)</author>
> <title>XML Developer's Guide</title>
> <genre>Computer</genre>
> <price>44.95</price>
> <publish_date>2000-10-01</publish_date>
> <descr>An in-depth look at creating applications with
> XML.</descr>
> </book>
> </catalog>
> """
We could definitely do this, but I can't figure out a simple set of rules that
would support both that and this:
let xml = """
<?xml version="1.0"?>
<catalog>
<book id="bk101" empty="">
<author>\(author)</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<descr>An in-depth look at creating applications with
XML.</descr>
</book>
</catalog>
"""
If we have to choose only one to support, I think the second syntax is the best
choice, because it does a better job of letting you format the literal
flexibly. Putting the first line of the literal on the same line as the
expression only works if the expression is short, as in this example. If the
expression is longer or more complicated, it starts to break down.
You could support both by saying that the leading newline is stripped if the
first line is blank, but that makes the rules more complicated and
unprincipled, not less.
(On the other hand, I believe that adding a backslash at the end of the first
line in my example would make it work with your algorithm. Hmm.)
> I think Brent did a super awesome job. The proposal is very detailed with a
> ton of examples. I think it covers just about everything that people have
> asked for.
Thanks! I really just swept in at the eleventh hour and wrote down what John
was thinking, though. (The phrase "mind reading skills" was used.) I didn't
work through these tradeoffs, hack several different designs into the compiler
to see how they'd work, and pick an actual design.
--
Brent Royal-Gordon
Architechies
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution