[swift-evolution] Class mutation model and value-constrained protocols
Chris Lattner
clattner at apple.com
Tue Jul 5 15:24:03 CDT 2016
On Jul 5, 2016, at 10:53 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> When T is a class type, it can easily violate *all* of these
> expectations. In other words, classes naturally bypass the mutation
> model.
>
> If we are going to maintain source stability after Swift 3, it seems
> that we either need to address this now, or decide that it won't be
> addressed, because of the “viral const” problem.
>
> One idea that Jordan and I have floated is that protocols with mutating
> methods should be constrained to applying to non-class types. That
> would be a step in the right direction, but, that still leaves cases
> like gg able to easily violate expectations when the protocol in
> question has no mutating methods.
>
> Another possibility would be to formalize the idea of value semantics in
> protocol declarations, so that non-class protocols were only allowed to
> apply to values.
>
> It's also possible that I've overestimated the seriousness of the issue
> and we actually can afford to postpone thinking about it until after
> Swift 4.
There is no chance that we will have time to re-evaluate this for Swift 3.
-Chris
More information about the swift-evolution
mailing list