[swift-dev] [Issue] Collection.distance() works not very well in some situations

2017-12-02 Thread Cao, Jiannan via swift-dev
[Issue] Collection.distance() works not very well in some situations The question is that, whether the original Collection Protocol requires index from lower to higher (startIndex < endIndex). If the original Collection Protocol requires index from lower to higher, than this infinity loop should

[swift-dev] [Proposal] RangeReplaceableCollection should inherits from MutableCollection

2017-12-02 Thread Cao, Jiannan via swift-dev
Hi everyone, I'd like to discuss the relation between RangeReplaceableCollection and MutableCollection MutableCollection is a Collection type that can { set } any element with subscript(position: Index). (and also { set } for subscript(range: Range)) RangeReplaceableCollection requires a func

[swift-dev] Equatable for two dimension array still not working (e.g. [[1]] == [[1]])

2017-12-02 Thread Cao, Jiannan via swift-dev
I used the swift-4.1-DEVELOPMENT-SNAPSHOT-2017-11-30-a-osx to test: Welcome to Apple Swift version 4.1-dev (LLVM 05fee6ff60, Clang f0e38d2044, Swift a1441d34f7). Type :help for assistance. 1> [[1]] == [[1]] error: repl.swift:1:7: error: binary operator '==' cannot be applied to two '[[Int]]' o

Re: [swift-dev] [Proposal] RangeReplaceableCollection should inherits from MutableCollection

2017-12-05 Thread Cao, Jiannan via swift-dev
Yes. ‘replaceSubrange(myRange, with: newCharacters)’ is different than subscript, because it may change the length. But any subscript could do that replaceSubrange could do, right? 在 2017年12月5日,10:48,Brent Royal-Gordon 写道: >> On Dec 2, 2017, at 12:31 PM, Cao, Jiannan via swi

Re: [swift-dev] [Proposal] RangeReplaceableCollection should inherits from MutableCollection

2017-12-05 Thread Cao, Jiannan via swift-dev
17, at 12:31 PM, Cao, Jiannan via swift-dev >> wrote: >> >> I'd like to discuss the relation between RangeReplaceableCollection and >> MutableCollection >> >> MutableCollection is a Collection type that can { set } any element with >> subscript(po

Re: [swift-dev] [Proposal] RangeReplaceableCollection should inherits from MutableCollection

2017-12-05 Thread Cao, Jiannan via swift-dev
s 写道: > > > > Sent from my iPhone > >> On Dec 5, 2017, at 12:19 AM, Cao, Jiannan via swift-dev >> wrote: >> >> >> But, I mean, what subscript (restrict to the length) could do is subset of p >> replaceSubrange could do, right? > >

[swift-dev] [Question] Why StringProtocol not inherit RangeReplaceableCollection?

2017-12-06 Thread Cao, Jiannan via swift-dev
Hi everyone, I have a question about StringProtocol. Since String and Substring are adopted RangeReplaceableCollection, why StringProtocol not inherit RangeReplaceableCollection? Also consider StringProtocol could inherit: CustomDebugStringConvertible CustomPlaygroundQuickLookable CustomReflecta

[swift-dev] [Question] Why StringProtocol not inherit RangeReplaceableCollection?

2017-12-06 Thread Cao, Jiannan via swift-dev
Hi everyone, I have a question about StringProtocol. Since String and Substring are adopted RangeReplaceableCollection, why StringProtocol not inherit RangeReplaceableCollection? Also consider StringProtocol could inherit: CustomDebugStringConvertible CustomPlaygroundQuickLookable CustomReflecta

[swift-dev] [Questions][SE-143]Conditional conformances for protocols?

2017-12-06 Thread Cao, Jiannan via swift-dev
Recently, we can use conditional conformances for struct/class. > extension Array: Equatable where Self.Element : Equatable { ... } Could we use conditional conformances for protocols? For example: > extension Collection : Equatable where Self.Element : Equatable { ... } Thanks! Jiannan __

[swift-dev] Make offset index available for String

2017-12-13 Thread Cao, Jiannan via swift-dev
Hi, I would like to discuss the String.Index problem within Swift. I know the current situation of String.Index is based on the nature of the underlaying data structure of the string. But could we just make String.Index contain offset information? Or make offset index subscript available for a

Re: [swift-dev] Make offset index available for String

2017-12-14 Thread Cao, Jiannan via swift-dev
up in real life? The most common > cases I see are trying to strip off the first or last character, or a known > prefix or suffix, and I feel like we should have better answers for those > than "use integer indexes" anyway. > > Jordan > > >> On Dec 13, 2

Re: [swift-dev] Make offset index available for String

2017-12-14 Thread Cao, Jiannan via swift-dev
String). These two offset is totally different. Best, Jiannan > 在 2017年12月15日,上午9:17,Michael Ilseman <mailto:milse...@apple.com>> 写道: > > > >> On Dec 14, 2017, at 4:49 PM, Cao, Jiannan via swift-dev > <mailto:swift-dev@swift.org>> wrote: >> >> Pe

Re: [swift-dev] Make offset index available for String

2017-12-14 Thread Cao, Jiannan via swift-dev
concept of UTF-16. > 在 2017年12月15日,上午9:25,Cao, Jiannan via swift-dev 写道: > > This offset is unicode offset, is not the offset of element. > For example: index(startIndex, offsetBy:1) is encodedOffset 4 or 8, not 1. > > Offset indexable is based on the offset of count of each

[swift-dev] [PITCH] Improve Optional Chain Assignment on Tuple Assignment

2017-12-15 Thread Cao, Jiannan via swift-dev
Hi all, I have come up an improvement point about Optional Chain Assignment 1. Optional Chain Assignment not working with tuple assignment optional chain assignment only work for directly assignment, not working with tuple assignment. For example: struct ListNode { var next: ListNode? }

Re: [swift-dev] Make offset index available for String

2017-12-18 Thread Cao, Jiannan via swift-dev
ifferent. >> >> Best, >> Jiannan >> >>> 在 2017年12月15日,上午9:17,Michael Ilseman >> <mailto:milse...@apple.com>> 写道: >>> >>> >>> >>>> On Dec 14, 2017, at 4:49 PM, Cao, Jiannan via swift-dev >>>> mail

Re: [swift-dev] Make offset index available for String

2017-12-18 Thread Cao, Jiannan via swift-dev
g data offset meaning to the UTF-16 String). >> >> These two offset is totally different. >> >> Best, >> Jiannan >> >>> 在 2017年12月15日,上午9:17,Michael Ilseman >> <mailto:milse...@apple.com>> 写道: >>> >>> >>> >>>>

Re: [swift-dev] Make offset index available for String

2017-12-18 Thread Cao, Jiannan via swift-dev
g data offset meaning to the UTF-16 String). >> >> These two offset is totally different. >> >> Best, >> Jiannan >> >>> 在 2017年12月15日,上午9:17,Michael Ilseman >> <mailto:milse...@apple.com>> 写道: >>> >>> >>> >>>>

Re: [swift-dev] Make offset index available for String

2017-12-18 Thread Cao, Jiannan via swift-dev
The encodedOffset is the underlaying offset of unicode string, not the same >>> concept of the offset index of collection. >>> >>> The offset indexable is meaning to the elements and index of collection >>> (i-th element of the collection), not related to the uni

Re: [swift-dev] Make offset index available for String

2017-12-18 Thread Cao, Jiannan via swift-dev
fset is totally different.Best,Jiannan在 2017年12月15日,上午9:17,Michael Ilseman <milse...@apple.com> 写道:On Dec 14, 2017, at 4:49 PM, Cao, Jiannan via swift-dev <swift-dev@swift.org> wrote:People used to the offset index system instead of the String.Index. Using offset indices to name the e