[swift-evolution] Class mutation model and value-constrained protocols

Anton Zhilin antonyzhilin at gmail.com
Tue Jul 5 14:27:42 CDT 2016

Personally, I'm fine with current state of things.

Firstly, I consider classes like a compatibility feature. They slightly
fall out of Swift type system. One can almost entirely avoid them, except
when interacting with ObjC. (They somehow code in Haskell, right?)

Secondly, when we interact with a struct (record), we expect it not to
mutate itself by default.
On the other hand, classes are black boxes, they represent some entity with
which we interact. It is natural for such entities to perform internal
mutation during operation.

> protocols with mutating methods should be constrained to applying to
non-class types
All methods of classes are implicitly mutating, so if something, then
protocols with non-mutating methods should be disallowed for classes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160705/3efb7a1e/attachment.html>

More information about the swift-evolution mailing list