[swift-evolution] Proposal: Re-instate mandatory self for accessing instance properties and functions

Greg Parker gparker at apple.com
Mon Dec 14 17:09:30 CST 2015


> On Dec 14, 2015, at 2:59 PM, Andrey Tarantsov via swift-evolution <swift-evolution at swift.org> wrote:
> 
> To me, self-access to properties in Objective-C is super-obtrusive, and I've been preferring fields for everything.

Note that the `self.property` access in Objective-C was not the preferred design. 

The first choice was for bare `property` to work. That turned out to be ambiguous too often because of identically-named ivars. Swift doesn't have that problem. 

The second choice was for bare `property` to access the property, requiring `self->ivar` to access an identically-named ivar. That was not feasible because it was incompatible with too much existing source code. Swift doesn't have that problem either.

Requiring `self.property` was the third choice.


-- 
Greg Parker     gparker at apple.com     Runtime Wrangler




More information about the swift-evolution mailing list