[swift-evolution] [Review] SE-0153: Compensate for the inconsistency of @NSCopying's behaviour
david at alkaline-solutions.com
Sat Feb 18 01:31:39 CST 2017
> Proposal link:
> https://github.com/apple/swift-evolution/blob/master/proposals/0153-compensate-for-the-inconsistency-of-nscopyings-behaviour.md <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?
Its an ugly problem. My preference would be to warn the developer to call copy manually for now, vs copy automatically.
The reason I’m concerned about the automatic approach is that I do not know if property behaviors are something which may still appear in a future version of Swift. At that point, I would expect NSCopying to become a behavior, and not a special case for initializer code generation.
If property behaviors are not planned for any future version of swift, then I suppose I’m impartial to the solution.
> Is the problem being addressed significant enough to warrant a change to Swift?
I think so; it won’t be clear to developers that initializers special-case property access, and silently going against their declared desired behavior is a bad idea.
> Does this proposal fit well with the feel and direction of Swift?
As stated above, I believe it depends on whether or not there is a future property behaviors spec that this would conflict with.
> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
In Ruby, the behavior is simpler - @foo will access the property value directly, while self.foo or some_reference.foo will use the ‘foo’ function. Dots are always used to invoke functions.
Objective C has a syntax for property access as well, in that you can refer to the synthesized property values directly via an underscore prefix.
A syntax for direct property data access in swift would be a third way to solve the problem. In that case, it would be clearer to the developer what they needed to do.
> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
A quick reading
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution