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

Torin Kwok torin at kwok.im
Sat Feb 18 05:57:53 CST 2017


Proposal link:

https://github.com/apple/swift-evolution/blob/master/proposals/0153-compensate-for-the-inconsistency-of-nscopyings-behaviour.md
Reply text:

However, occasionally a constructor might be non-copying on purpose, so we'll need a way to disable the warning.
How about the determination method mentioned in the proposal:

... if developers are performing an assignment operation from within an initializer between a property declared as @NSCopyingand an instance of a protocol conforming class.
That is, there are two key factors determining whether a fixable error or warning should be emitted:

If the destination property has been declared as @NSCopying in class definition
If the source value conforms to <NSCopying> protocol
Once both are true, then what compiler can be sure about is that developer definitely missed the required manual copy invocation and it would emit either an error or a warning correspondingly. Otherwise, compiler would not complain of anything and would just leave the decision up to developers.


> On 18 Feb 2017, at 18:16, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Feb 17, 2017, at 3:18 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> 
>> https://github.com/apple/swift-evolution/blob/master/proposals/0153-compensate-for-the-inconsistency-of-nscopyings-behaviour.md
>> 
>> 	• What is your evaluation of the proposal?
> 
> I think a warning is very appropriate.
> 
> However, occasionally a constructor might be non-copying on purpose, so we'll need a way to disable the warning. A few possibilities:
> 
> * Use .self on the value
> * Parenthesize the value
> * Parenthesize the variable
> 
> I don't favor using compiler magic. Too spooky.
> 
>> 	• Is the problem being addressed significant enough to warrant a change to Swift?
> 
> Yeah, that's a pretty easy mistake to make.
> 
>> 	• Does this proposal fit well with the feel and direction of Swift?
> 
> Yes. Swift usually tries to help you avoid mistakes.
> 
>> 	• If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 
> N/A.
> 
>> 	• How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
> Quick reading.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170218/fcf1b036/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/fcf1b036/attachment.p7s>


More information about the swift-evolution mailing list