[swift-evolution] [Pitch] Removing Setter/Observer Name Overrides

Brent Royal-Gordon brent at architechies.com
Sun Dec 4 04:31:19 CST 2016


> On Dec 3, 2016, at 7:06 PM, Erica Sadun <erica at ericasadun.com> wrote:
> 
> A majority of respondents prefer that argument names always be mentioned, 
> whether or not they *can* be omitted. Consensus is that it's unSwifty
> to use pre-built `newValue` and `oldValue` arguments without mentioning
> them first.

For what it's worth, I don't agree that the default names are a problem. I think they're a helpful convenience which, nevertheless, must occasionally be overridden because they conflict with the name of something else. The names are well-chosen and virtually always read correctly.

(Also FWIW, I'm not sure I've ever explicitly named the `oldValue`/`newValue` variable rather than using the implicit names.)

I think a warning on using `oldValue` instead of `newValue` or vice versa would be very helpful and address the parts of this proposal which aren't motivated by mere style complaints. The rest I think is a style issue, and I don't think that style issue is nearly universally-agreed-upon or serious enough to motivate a breaking change affecting tons of property setters, property observers, and subscript setters.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list