[Swift] C-style static string concatenation is unsupported

Originator:amolloy
Number:rdar://17302399 Date Originated:6/13/14
Status:Closed Resolved:As Intended
Product:Developer Tools Product Version:
Classification: Reproducible:
 
In C (and very many other languages), it is possible to have the compiler concatenate static strings separated by only whitespace:

const char* cString = "This " "works fine.";

In contrast, Swift requires to explicitly include the string concatenation operator, +:

let swiftString = "This " + "works fine."
let otherSwiftString = "This " "does not."

While requiring the concatenation operator is not the worst thing in the world, it does put more work that could be done by the compiler onto the programmer. It also results in more rigid code, as the programmer will always have to maintain the + operators when modifying the string code. This is especially evident in multi-line examples:

let someLongString = "Jean shorts pug yr, nihil shabby chic synth ugh Carles Blue Bottle" + 
"sunt PBR&B McSweeney's fashion axe photo booth fingerstache. Kogi photo booth mollit " +
"narwhal et readymade. DIY biodiesel enim YOLO sint, cliche authentic selvage Tonx. Carles " +
"cardigan XOXO crucifix placeat. Vegan dolor incididunt selfies sint. Aliquip pour-over " +
"sint officia, sriracha sustainable selvage. Artisan bicycle rights brunch, authentic " + "gentrify pickled stumptown banh mi magna quis in."

If you need to add a new paragraph, you have to add a + operator beforehand, or if you need to remove the last line you have to remove the + operator from the proceeding line. This is minor, but it is something the compiler could be worrying about instead of the programmer.

Steps to Reproduce
1. Create a new playground in Xcode
2. Enter the following:

var str = "Hello, playground" ", how are you?"
let otherStr = "Another try, " "at string concatenation"

foo("Does this"
	"work?")

(Or open the attached playground).

Expected Results
This should be accepted by the compiler.

Actual Results
The compiler rejects this code.

Configuration
Any

Xcode Version
Xcode 6 Beta 1

Additional Notes

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!