> On 20 Jan 2017, at 10:30, Maxim Veksler via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> One ask - make string interpolation great again?
> 
> Taking from examples supplied at 
> https://github.com/apple/swift/blob/master/docs/StringManifesto.md#string-interpolation
> 
> "Column 1: \(n.format(radix:16, width:8)) *** \(message)"
> 
> Why not use:
> 
> "Column 1: ${n.format(radix:16, width:8)} *** $message"
> 
> Which for my preference makes the syntax feel more readable, avoids the 
> "double ))" in terms of string interpolation termination and function 
> termination points. And if that's not enough brings the "feel" of the 
> language to be scriptable in nature common in bash, sh, zsh and co.. 
> scripting interpreters and has been adopted as part of ES6 interpolation 
> syntax[1]. 
> 

This idea came up once before on Swift Evo. The arguments against are:

1. Swift already has an “escape” character for inserting non literal stuff into 
strings - the “\” character. Either you have two - increasing complexity for 
both the developer and the Swift compiler’s tokeniser - or you have to change 
everything that uses “\” to use $ e.g. $t $n instead of \t \n.  

2. The dollar sign is a disastrous symbol to use for an special character, 
especially in the USA where it is commonly used to signify the local currency. 
Yes, I know it is used for interpolation in Perl, Shell and Javascript and 
others,  but “this other language I like does X, therefore Swift should do X” 
is not a good argument.

3. There is already quite a lot of code that uses \( … ) for interpolation, 
this would be a massive breaking change.

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to