> On Apr 26, 2017, at 9:12 PM, John McCall via swift-evolution 
> <[email protected]> wrote:
> 
>> 
>> Is that a mistake? Wouldn't the free function forward to the added method?
> 
> I'm not sure why this is there.  The implementation of the method is not part 
> of the library specification.  If it forwards to the free function for some 
> reason, it'll be via internal implementation details that certainly don't 
> need to be described in this proposal.

It was there purely to explain why it was necessary to add an otherwise 
seemingly pointless method to MutableCollection. Needed because of 
https://bugs.swift.org/browse/SR-4660 <https://bugs.swift.org/browse/SR-4660> – 
in short, if you have a method on self, you cannot call the free function of 
the same name without full qualification, even if argument labels or different 
types make it clear which one was intended. So adding swap(_:with:) to 
MutableCollection would break code currently calling swap(&a,&b), which would 
need to change to Swift.swap(&a,&b). So we would have to put in an extra swap 
method on MutableCollection, that in turn calls Swift.swap, for source 
compatibility reasons.

However, if we adopt the preferred base name swapAt instead, this won’t be 
necessary.

(it will be necessary to add similar workarounds for min and max to String when 
it becomes a Collection, though...)


_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to