You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift's Collection protocol has a number of nontrivial semantic constraints that are rather under-documented; one of these is that a collection's SubSequence must be a collection that shares indices with the original instance. (The type system is currently not even able to enforce the requirement about SubSequence being a collection, or that its index type must be the same as the top-level collection. Presumably, these are going to be fixed, but the requirement about sharing index values is unlikely to be ever enforced by the type system.)
Slices of valid collections should have their start index the same as the index of their starting element in the original collection. BTree gets this wrong:
let list = List(0 ..< 10)
print(list[3 ..< 10].startIndex) // ==> 0
let array = Array(0 ..< 10)
print(array[3 ..< 10].startIndex) // ==> 3
This means BTree's collection types aren't really collections.
The way to fix this is to replace the custom SubSequence typealiases with one of the default Slice types in each. This is a source-breaking change, so it requires a major version bump.
The original BTree slicing behavior (i.e., extracting a separate sub-collection of the same type) will be moved to a family of functions (list.extract(3..<10) or list.sublist(3..<10) or somesuch).
The text was updated successfully, but these errors were encountered:
Swift's
Collection
protocol has a number of nontrivial semantic constraints that are rather under-documented; one of these is that a collection'sSubSequence
must be a collection that shares indices with the original instance. (The type system is currently not even able to enforce the requirement aboutSubSequence
being a collection, or that its index type must be the same as the top-level collection. Presumably, these are going to be fixed, but the requirement about sharing index values is unlikely to be ever enforced by the type system.)Slices of valid collections should have their start index the same as the index of their starting element in the original collection.
BTree
gets this wrong:This means
BTree
's collection types aren't really collections.The way to fix this is to replace the custom
SubSequence
typealiases with one of the default Slice types in each. This is a source-breaking change, so it requires a major version bump.The original BTree slicing behavior (i.e., extracting a separate sub-collection of the same type) will be moved to a family of functions (
list.extract(3..<10)
orlist.sublist(3..<10)
or somesuch).The text was updated successfully, but these errors were encountered: