[swift-evolution] ed/ing, InPlace, Set/SetAlgebra naming resolution

Greg Parker gparker at apple.com
Fri Feb 12 00:34:56 CST 2016


> On Feb 11, 2016, at 10:33 PM, David Owens II via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Feb 11, 2016, at 10:30 PM, Chris Lattner <clattner at apple.com> wrote:
>> 
>>> On Feb 11, 2016, at 10:28 PM, David Owens II via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> I don’t know if this has been suggested already… but why not just use the same name and have an `inPlace` parameter with a default value?
>> 
>> inplace, or not, fundamentally affects the operation, including the return type.  On a struct, it is the different between the method being mutating or not.
>> 
>> -Chris
> 
> The return type is not always different, but in the case where it is and when we need mutating, can’t overloads solve this problem?
> 
> mutating func sort() {}
> func sort(inPlace: Bool) -> T {}
> 
> Maybe I’m just overlooking something really obvious here…

x.sort(inPlace: true) can't work with those definitions.


-- 
Greg Parker     gparker at apple.com     Runtime Wrangler




More information about the swift-evolution mailing list