> On Jan 12, 2017, at 1:37 PM, Slava Pestov via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
>> Before I submit it, could someone let me know if adding generics to 
>> subscripts would influence the ABI? ( still feel pretty clueless in that 
>> area).
> 
> It won’t change the ABI of existing subscript calls, but if the standard 
> library introduces new generic subscripts that replace older non-generic 
> subscripts, it will impact ABI.
> 

Specifically, we currently have to have a _Hashable protocol that has a 
_toAnyHashable() method in order to implement Dictionary<AnyHashable,*> 
subscripting using concrete types as keys. A replacement subscript that was 
generic over all Hashable types would solve this more neatly, and would be 
source-compatible, but affects the ABI of the stdlib. 

https://github.com/apple/swift/blob/master/stdlib/public/core/Hashable.swift#L16

Generic subscripts would also make it easier to implement one-sided ranges e.g. 

        myCollection[i...] // slice from i to the end


_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to