[swift-evolution] multi-line string literals
Etan Kissling
kissling at oberon.ch
Tue Dec 15 10:30:15 CST 2015
@1: Or Xcode could simply continue the string if you hit enter without terminating it. (Same if you open a string literal, and then paste a multiline text)
To copy out of Xcode, use alt-click selection to cut away leading ".
@2: +1
@3: +1. Don't see the point why this should be better than simply adding strings up with +.
Generally, I'm kind of sceptical about this. Especially trailing whitespace becomes invisible.
You don't know if your editor cuts out trailing whitespace. You no longer see where each line ends.
Maybe with Xcode, the IDE could display kind of a rectangle that shows what's the left / right border of each line
(maybe background color the parts that are within the string, so you actually see trailing whitespace).
Still, even then I fail to see the real need for multiline string literals if you assume that your IDE is smart enough
to detect whether you are editing a string, and to automatically insert the " + on the current line and the indentation " on the next line
when you press enter or paste a multiline text in that context.
-1 for Heredoc proposal. It's just ugly, and even in languages that have it (e.g. PHP) I've never seen it used in current code,
with the exception of XML (where it's the only option I guess).
As for escaping vs non-escaping, just adding a few other languages as reference.
PHP uses " ... " to denote strings with interpolation and \n transformation etc., and ' ... ' for verbatim strings.
C# uses " ... " for normal strings and @" ... " for verbatim strings (e.g. Windows paths that incorporate lots of \).
Etan
> On 14 Dec 2015, at 23:21, Andrey Tarantsov via swift-evolution <swift-evolution at swift.org> wrote:
>
>> Yes, you are right, Brent, there should be a closing quote on the last line otherwise it would be a syntax error. That’s a much better idea! That would also fix the
>>
>> let x = “foo
>>
>> being valid syntax problem.
>
>
> Guys, you know this is crazy, right? :-)
>
> 1) copy & paste would be really annoying (on that note, Xcode should totally get multiple cursors support like in Sublime)
>
> 2) any non-specialized syntax highlighter would parse them all completely incorrectly, which is not a show-stopper, but shouldn't be taken lightly. (Think a generic indented code block in Markdown on GitHub.)
>
> 3) it's just cruel — https://xkcd.com/859/ <https://xkcd.com/859/>
>
> <(.png>
>
> A.
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151215/50fda5a8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151215/50fda5a8/attachment.sig>
More information about the swift-evolution
mailing list