[swift-evolution] multi-line string literals.
John Holdsworth
mac at johnholdsworth.com
Thu May 5 19:08:29 CDT 2016
> On 5 May 2016, at 14:17, David Hart <david at hartbit.com> wrote:
>
>
>> On 05 May 2016, at 12:30, Michael Peternell via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>> it's not a secret that I'm not a big fan of the proposal. The third draft doesn't change this and it's unlikely that any future draft will, because for me, the problem are the continuation quotes, and for Brent it seems like they are a must-have-feature (correct me if I'm wrong.)
>
> I agree with all you said. I’m fairly sure I would never vote for Brent’s proposal simply because of the existence of continuation quotes, no matter the amount of reasoning behind it. They are simply too unwieldy, cumbersome and unfriendly to modification.
>
> I could see either your proposal, or your proposal without the HERE_DOCs but using Tyler’s/Scala’s .stripMargin. Do you think you could start a formal proposal?
Adapting the original proposal if you’re not a fan of continuation quotes..
It’s possible to have a multiline “””python””” multi-line string but tidily indented.
As suggested earlier in this thread the lexer can strip the margin on the basis of
the whitespace before the closing quote as per Perl6 (This could be a modifier “I”
but might as well be the default TBH.) Would this be the best of both worlds?
assert( xml == i"""
<?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>
<description>An in-depth look at creating applications with XML.</description>
</book>
</catalog>
""” )
Other modifiers can also be applied such as “no-escapes"
assert( xml != ei"""<?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>
<description>An in-depth look at creating applications with XML.</description>
</book>
</catalog>
""" )
I’d hope this would satisfy any need for <<HERE/<<‘HERE’ style constructs.
Or you could support both continuation and indented python style:
http://johnholdsworth.com/swift-LOCAL-2016-05-05-a-osx.tar.gz <http://johnholdsworth.com/swift-LOCAL-2016-05-05-a-osx.tar.gz>
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160506/b70f0ed9/attachment.html>
More information about the swift-evolution
mailing list