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

Dmitri Gribenko gribozavr at gmail.com
Fri Apr 15 16:19:47 CDT 2016


On Fri, Apr 15, 2016 at 1:30 PM, Stephan Tolksdorf <st at quanttec.com> wrote:
> On 2016-04-12 Dmitri Gribenko via swift-evolution wrote:
>>
>> Not even to mention that
>> indices are valid only in context of a particular collection instance,
>> so in this model you could validate an index against one collection
>> and use it with another one.
>
>
> 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.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list