[swift-evolution] [Pitch] String revision proposal #1

Ben Cohen ben_cohen at apple.com
Thu Mar 30 18:43:41 CDT 2017


> On Mar 30, 2017, at 10:05 AM, Karim Nassar via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> Message: 12
>> Date: Thu, 30 Mar 2017 12:23:13 +0200
>> From: Adrian Zubarev <adrian.zubarev at devandartist.com>
>> To: Ben Cohen <ben_cohen at apple.com>
>> Cc: swift-evolution at swift.org
>> Subject: Re: [swift-evolution] [Pitch] String revision proposal #1
>> Message-ID: <etPan.58dcdc91.583a4c4b.1af7 at devandartist.com>
>> Content-Type: text/plain; charset="utf-8"
>> 
>> I haven’t followed the topic and while reading the proposal I found it a little confusing that we have inconsistent type names. I’m not a native English speaker so that’s might be the main case for my confusion here, so I’d appreciate for any clarification. ;-)
>> 
>> SubSequence vs. Substring and not SubString.
>> 
>> The word substring is an English word, but so is subsequence (I double checked here).
>> 
>> So where exactly is the issue here? Is it SubSequence which is written in camel case or is it Substring which is not?
>> 
>> 
>> 
>> -- 
>> Adrian Zubarev
>> Sent with Airmail
> 
> 
> I’d also be curious if StringSlice was considered, since we have already the well-established and seemingly-parallel ArraySlice.
> 

Yup we considered it (I should probably have put it in the Alternatives Considered section). Also considered: having nothing but String.SubSequence. In fact it may be Substring is just a typealias for String.SubSequence, though this would be an implementation detail rather than part of the proposal.

The current hope (unrelated to String) is that ArraySlice could be eliminated, by introducing some kind of “ContiguouslyStored” protocol and then extending the general Slice when it slices something that conforms to that. But this can’t be done with Substring because of the small string optimization.

The other difference is there’s no common term of art for a slice of an Array, whereas there is for a slice of a String.

> —Karim
> 
> _______________________________________________
> 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