AFAIK, there was an optimization for literal string concatenation that was 
broken in Xcode 8.3 (and the Swift version that comes with it), but is now 
fixed in master.

https://bugs.swift.org/browse/SR-4348 <https://bugs.swift.org/browse/SR-4348>

> On May 16, 2017, at 10:47 PM, Ben Rimmington via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> 
>> On 16 May 2017, at 21:27, Tony Allevato <tony.allev...@gmail.com> wrote:
>> 
>>> On Tue, May 16, 2017 at 1:25 PM David Hart <da...@hartbit.com> wrote:
>>> The problem I see is that + is an operator of the Standard Library and not 
>>> part of the core language. I wouldn’t want + to sometimes to be a runtime 
>>> operation and other times a compile-time operation. No, I really think we 
>>> need strong language support here.
>> 
>> Why not? Compile-time concatenation of string literals delimited by `+` 
>> sounds like a perfectly reasonable compiler optimization.
>> 
>> Your argument would also state that the compiler should not do constant 
>> folding like turning `5 + 7` into `12`, would it not? What makes that 
>> situation different?
> 
> When does the compiler do constant folding?
> 
>       Welcome to Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42). 
> Type :help for assistance.
>         1> import Foundation
>         2> let x: NSNumber = 12
>       x: __NSCFNumber = Int64(12)
>         3> let y: NSNumber = 5 + 7
>       error: repl.swift:3:21: error: cannot convert value of type 'Int' to 
> specified type 'NSNumber'
>       let y: NSNumber = 5 + 7
>                         ~~^~~
>                         NSNumber( )
> 
> -- Ben
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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

Reply via email to