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

Andrey Tarantsov andrey at tarantsov.com
Mon Dec 14 16:59:35 CST 2015

> Most of the time, your UIViewController or UITableViewController’s self.tableView is the same object as UITableViewDelegate’s tableView method argument. But I’ve had several cases in my app development career where that UIViewController was also used for updating a different tableView (for example a tableView used for search) which uses the same delegate, but where it is paramount to use the argument variable and not the instance variable.
> I’ve actually had a bug due to that where code review was very quick because cellForRowAtIndexPath was using self.tableView instead of tableView and we saw it straight away.

Like I've mentioned, I also had a couple bugs like that, but I'll take that bug rate over the day-to-day requirement to use self.

>>> (3) the code is fairly verbose as it is, and adding any extra syntactic elements obscures its intention.
> Like many before, I think this is a question of taste. In our team, we don’t find it particularly verbose and we actually think it clarifies intention.

I guess you can get used to it? To me, self-access to properties in Objective-C is super-obtrusive, and I've been preferring fields for everything.

Now, I've expressed my opinion, and I have no idea how to resolve an issue that basically boils down to one's taste (I don't buy the extra-bug-a-year being a compelling argument), so I'll let you guys continue with the discussion. :-)


More information about the swift-evolution mailing list