<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">If implemented as an argument to `<span class="" style="color:rgb(121,93,163);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.8px;white-space:pre">Lexer::lexStringLiteral</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.8px;white-space:pre">()</span>`, then it would behave exactly like a typical string literal except where multi-line behavior is concerned (and being terminated by triple quotes instead of a single quote). This would include interpolation, as well as any future functionality.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">The function in question wouldn't require much modification: </div><div class="gmail_default" style="font-family:verdana,sans-serif"><a href="https://github.com/apple/swift/blob/0bfba2972ec718bb23c006d5fdd9736c506f681e/lib/Parse/Lexer.cpp#L1121">https://github.com/apple/swift/blob/0bfba2972ec718bb23c006d5fdd9736c506f681e/lib/Parse/Lexer.cpp#L1121</a></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">As well as slight modification here to detect triple quoted strings and pass on that information: </div><div class="gmail_default" style="font-family:verdana,sans-serif"><a href="https://github.com/apple/swift/blob/0bfba2972ec718bb23c006d5fdd9736c506f681e/lib/Parse/Lexer.cpp#L1654-L1656">https://github.com/apple/swift/blob/0bfba2972ec718bb23c006d5fdd9736c506f681e/lib/Parse/Lexer.cpp#L1654-L1656</a></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">But that would be an implementation detail, and only if others agree to using triple quote syntax.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">- Travis Tilley</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 10, 2015 at 5:43 PM, Tal Atlas <span dir="ltr"><<a href="mailto:me@tal.by" target="_blank">me@tal.by</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Conceptually for this, especially for server side utility. I think there’s a plethora of options out there, “”” seems to be the most modern one, and i’d vote for it having the same interpolation as standard strings \()</div><br><div class="gmail_quote"><div><div class="h5"><div dir="ltr">On Thu, Dec 10, 2015 at 4:57 PM Travis Tilley via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div style="font-family:verdana,sans-serif">I would very much like to implement multi-line string literals in swift and get feedback on what this should look like, as i've been informed there are several competing suggestions filed as radars.</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">My initial improvement request is here: <a href="https://bugs.swift.org/browse/SR-170" target="_blank">https://bugs.swift.org/browse/SR-170</a></div><div style="font-family:verdana,sans-serif"><br></div><div><font face="verdana, sans-serif">It is only an opinion, but it's my belief that simple python-style multi-line string literals are the way to go. They're simple and, in the end, exactly the same as normal string literals. They begin and end with triple quotes, can contain newlines, can contain single quotes, and that's all that's special in their parsing. The same block of code in Lexer.cpp could be used for both types of literal, ensuring behavior is always consistent regardless of any future changes.</font></div><div><font face="verdana, sans-serif"><br></font></div><div style="font-family:verdana,sans-serif">There is also the potential suggestion of removing consistent indentation if there is any so as to make formatting of a multi-line string literal look more clean when indented. For me, it would be a nice to have, but not a make or break feature... and for some it may be confusing.</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">I'd like to state that I'm not proposing heredoc-style functionality, as I believe that to be an entirely separate feature. The potential to have one heredoc embedded within another would certainly make parsing more painful than i'm happy with.</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">For an example of code that would benefit significantly from multi-line string literals, please look at docopt.swift: <a href="https://github.com/docopt/docopt.swift/blob/master/Examples/Swift/arguments_example/main.swift#L9-L25" target="_blank">https://github.com/docopt/docopt.swift/blob/master/Examples/Swift/arguments_example/main.swift#L9-L25</a></div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">Docopt does the opposite of what most command line argument libraries do: rather than defining options and auto-generating the help text based on that... You write the help text and it auto-generates a CLI with exactly those options and arguments. It makes writing CLI applications an absolute pleasure, but without multi-line string literals in swift it's currently less pleasant than it could be.</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">Please send me your thoughts. ^_^b</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif">-Travis Tilley</div><div style="font-family:verdana,sans-serif"><br></div><div style="font-family:verdana,sans-serif"><br></div>
</div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RVJ3oK8DhV2nk8GArr3gdFC-2F0OoRGI24k7f-2BQraS0fLFRBLcIYEkgKGAXMbSgVMORhd5Yb9S8Xyt5uxea9VxgaEK0X-2Ba6ESPATgweSWSeSb4RbCi5pZOZU-2BB-2BiZttfjBXyZ-2F-2F25ngmRcwIYYcIZ5ie7frb31E22WkxyswoXY-2FiWRmzQemaWG2RhfTnjjyN7KkUAaSo7lEG3t6LRhDI-2BNFA-3D-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;">
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>
</blockquote></div><div><br></div>
</div></div>