[swift-evolution] [Review] SE-0065 A New Model for Collections and Indices

Stephan Tolksdorf st at quanttec.com
Fri Apr 15 18:24:54 CDT 2016

On 2016-04-15 Dmitri Gribenko wrote:
>> On Fri, Apr 15, 2016 at 1:30 PM, Stephan Tolksdorf <st at quanttec.com> wrote:
>> The proposal requires Index values to be Comparable. Does that mean that
>> indices from different collection instances should be comparable i.e. have a
>> strict total order?
> No, comparing indices from unrelated instances produces unspecified
> results (incl. traps).

>> And somewhat related: Is it safe in Swift (in contrast to C) to compare
>> NativePointers into unrelated memory blocks?
> Unfortunately, I don't know, but I'd like to know the answer, too :)
> I don't think this is documented anywhere though, so it is technically
> unspecified.

Thanks for your reply!

These kind of type-specific special preconditions for the Comparable 
protocol probably should be documented more prominently. A similar case 
is the behaviour of the Comparable implementation for floats when NaNs 
are involved.

- Stephan

More information about the swift-evolution mailing list