[swift-evolution] [Review] SE-0153: Compensate for the inconsistency of @NSCopying's behaviour

Torin Kwok torin at kwok.im
Sat Feb 18 02:35:14 CST 2017


Hello Swift community:

Thank you for your reviews for my proposal. As you may have seen, this proposal contains two solutions originally:

Compiler magic
Compile-time checking
However even though Solution: Compiler magic is viable, according to some of feedback from several reviewers, a developer who is new to Swift would continue to be misled by the introduction of the automatic copy behavior:

from Xiaodi Wu xiaodi.wu at gmail.com <mailto:xiaodi.wu at gmail.com>:

A person who is new to Swift would continue to be confused if @NSCopying had magic but didSet and other behaviors did not. A person who has studied Swift and internalized the reasoning behind this initially tricky situation might rightly expect that all behaviors, including @NSCopying, are ignored during init.
from David Hart david at hartbit.com <mailto:david at hartbit.com>:

For the same reasons as Xiaodi, this proposal could be potentially misleading if it introduces custom compiler magic, warning or errors that was not replicated for future property behaviours.
For this consideration, I decided to lower the priority of Solution: Compiler magic to Alternatives Considered section and leave Solution: Compile-time checking as the only one major solution, which suggests that compiler warns the developers to call copy manually, rather than implicit magic:

Have compiler emit a compile-time error or warning if developers are performing an assignment operation from within an initializer between a property declared as @NSCopying and an instance of a protocol conforming class.
I’ve already submitted a pull-request for this modification.

Best,

Torin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170218/0b768662/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3561 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170218/0b768662/attachment.p7s>


More information about the swift-evolution mailing list