[swift-evolution] mutating/non-mutating suggestion from a Rubyist

Daniel Steinberg daniel at dimsumthinking.com
Fri Apr 22 03:28:00 CDT 2016


Sorry I left mutating off by mistake. I'm referring to the call site more

> On Apr 22, 2016, at 8:40 AM, Krishna Kumar <kkdevenda at gmail.com> wrote:
> 
> Hey
> 
> I think adding “&” to methods will reduce the readability of the code. Also, keyword “mutating” makes it super clear and readable that my method is mutating the values.
> 
> 1. mutating func add(value: Double){…}
> 
> 2. func add&(value: Double){…}
> 
> I think it’s easy to skip the information encoded into the 2nd function which is this function is mutating a value as compared to 1st. When I read 1st function I start reading with keyword “mutating” making its intentions clear to me.
> 
> Also, it might become a symbol nightmare with following type signature of a function-
> 
> func nightmare&(title: String?) -> String? -> String?{…}
> 
> I can see the advantage of using “&” when calling a function. It makes clear at the call site that this method is mutating but still I don’t find eliminating “mutating” a good step for the reasons mentioned above.
> 
> Maybe we can think of some better solution.
> 
> Thanks
> 
> -Krishna
> 
>> On Apr 21, 2016, at 10:38 PM, Daniel Steinberg via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> swift-evolution at swift.org
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160422/0ee25b40/attachment.html>


More information about the swift-evolution mailing list