[swift-evolution] Strings in Swift 4

Dave Abrahams dabrahams at apple.com
Fri Jan 20 09:08:41 CST 2017


Sent from my iPad

> On Jan 19, 2017, at 8:13 PM, David Sweeris <davesweeris at mac.com> wrote:
> 
> 
> 
> Sent from my iPhone
> 
>> On Jan 19, 2017, at 20:56, Ben Cohen via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> Hi all,
>> 
>> Below is our take on a design manifesto for Strings in Swift 4 and beyond.
>> 
>> Probably best read in rendered markdown on GitHub:
>> https://github.com/apple/swift/blob/master/docs/StringManifesto.md
>> 
>> We’re eager to hear everyone’s thoughts.
>> 
>> Regards,
>> Ben and Dave
> 
> An enthusiastic +1
> 
> A couple more quick thoughts...
> 
> 1) Is it just me, or is explicitly putting some of the "higher level" functionality in Foundation instead of stdlib kinda reminiscent of MVC? I guess UIKit/Cocoa would be the "View" part.

Might just be you ;-)

> 2) I like the idea of making String generic over its encoding... Would we need to nail down the hypothetical type promotion system for that to work, or can it all be handled internally?

If you're implicitly asking what the type of s1 + s2 is when they have different encodings,
I don't think we need a type promotion system to handle that.  Unlike with fixed-width integers, there is a family of maximally-expressive encodings that can be used for the result of any operation whose result would otherwise be in doubt without any serious loss of performance.  I would probably just go with the currency type, "String" for these cases.

Cheers,
--
Dave


More information about the swift-evolution mailing list