[swift-evolution] [Pitch] Improve String Literals

Adrian Zubarev adrian.zubarev at devandartist.com
Tue May 16 08:39:23 CDT 2017


Well the main complain I had during the discussion with David was, that I previously had such a model in mind which will break up long double-quoted string literals. Please look up this design in the alternative section of our proposal. By adding slightly redundant multi-line string literal syntax for consistency renders that complain to zero. By allowing:

"
SELECT 'name'
FROM 'people'
WHERE age > 20
"
it becomes clear that the trailing backslash should only be used for escaping new line injection in multi-line string literals, but not for breaking up long strings (similar to other languages like JavaScript):

"SELECT 'name' \
FROM 'people' \
WHERE age > 20"
This also lets us adopt the C/Objective-C syntax instead.

"SELECT 'name' "
"FROM 'people' "
"WHERE age > 20"


-- 
Adrian Zubarev
Sent with Airmail

Am 16. Mai 2017 um 15:02:06, Gwendal Roué via swift-evolution (swift-evolution at swift.org) schrieb:

I wonder whether this addition was introduced in order to make the proposal as consistent as possible, and prevent some criticisms. It has proven pointless. I suggest forgetting about pleasing people who don't want to be pleased, and to reconsider this "divorce" section. Consistency is not the main point. The main point is UX. This means easing the daily life of code writers, and easing the daily life of code readers (this involves being careful which text editors and code prettyfiers are unable to handle the proposal).

> Support escaping newlines in multi-line strings with a trailing \

Great. That's the main request, unless I'm misled: split long literals accross multiple lines. 

Now that Xiaodi Wu has found them, the core team questions about the trailing backslash should be addressed in more details.

> Adopt the C/Objective-C syntax that concatenates single-line strings

A battle-tested solution. Doesn't it look redundant with both the "divorce" and the trailing backslash?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170516/58269c30/attachment.html>


More information about the swift-evolution mailing list