[swift-evolution] Strings in Swift 4

Jose Cheyo Jimenez cheyo at masters3d.com
Fri Jan 20 00:42:51 CST 2017

Hi Ben,

I just have one concern about the slice of a string being called Substring. Why not StringSlice? The word substring can mean so many things, specially in cocoa. 

Thank you. Great manifesto. 

> On Jan 19, 2017, at 8:18 PM, Ben Cohen via swift-evolution <swift-evolution at swift.org> wrote:
>> On Jan 19, 2017, at 19:38, David Sweeris <davesweeris at mac.com> wrote:
>> Regarding substrings... Instead of having separate `ArraySlice` and `Substring` types, what about having just one type, `Slice<T: Sequence>`, for anything which shares memory? Seems like it'd be easier for users who'd only have to worry about shared storage for one type, and for stdlib authors who'd only have to write it once.
> Collections already do get a default SubSequence implementation of Slice<Base: Indexable> that is essentially like just that. 
> The reason types like Array and String have their own is to customize it with more than the default behavior. For example, ArraySlice provides .withUnsafeBufferPointer  method just like an Array does. Substring would need all the features String provides.
> Now, once we get conditional conformance, we could use that to maybe increase sharing, for example we could create a protocol for types backed by contiguous memory that provided withUnsafeEtc, and then use conditional conformance to add those features to Slice when the Base has them. This probably won't improve user experience particularly though, just help library authors organize/minimize the code.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list