[swift-evolution] Allowing mutable members in structs
Dan Raviv
dan.raviv at gmail.com
Fri Mar 11 04:38:27 CST 2016
Would it make sense to allow mutable properties in structs, which could be
mutated even by non-mutating methods?
I've noticed this could be useful when implementing a non-mutating protocol
method. The method semantically doesn't change the state of the protocol's
implementor, and therefore shouldn't be declared as mutating. However,
*some* implementations might need to change some internal state for
implementing the functionality. Making specific struct properties mutable
for such a case could make sense.
Alternatively, Swift could allow implementing a non-mutating protocol
method as a mutating method in the implementor. Currently, this doesn't
seem to be allowed; Swift doesn't recognize the mutating method as a match
for the non-mutating protocol method.
Cheers,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160311/69a94ee2/attachment.html>
More information about the swift-evolution
mailing list