[swift-evolution] Immutable Structures
Lino Rosa
lino.aguiar.rosa at gmail.com
Fri Dec 25 11:47:41 CST 2015
To me documentation plus the type signatures are generally enough. However
I could probably still agree with you if mutating was also used in classes.
What's the point of having it only on structures?
On Fri, Dec 25, 2015 at 12:32 T.J. Usiyan <griotspeak at gmail.com> wrote:
>
>>
>> I don’t understand why we need the `mutating` keyword in the first place.
>> Is it for readability? Right now the compiler knows when a function mutates
>> a property and forces us to write `mutating`. Couldn’t it just fail
>> compiling when try to call a mutation function but we’re not allowed?
>>
>>
> I strongly disagree with this sentiment. I agree that the compiler can
> figure it out without us in many cases but I appreciate knowing
> *explicitly* which parts of an API will mutate a value. It is helpful for
> both the vendor and consumer of the API to require that keyword.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151225/3cca9439/attachment.html>
More information about the swift-evolution
mailing list