[swift-evolution] Proposal: Re-instate mandatory self for accessing instance properties and functions (David Hart)
kevin at sb.org
Tue Dec 8 19:24:10 CST 2015
I agree, this change does not bring clarity. It just adds noise (`self.` everywhere) and removes the ability to use elided self as a reminder to watch out for retain cycles when creating escaping closures.
If you're teaching students and you're worried about mixing up local variables and properties, then feel free to always include the `self.` in your lessons. I don't see why the language has to change to enforce this one particular stylistic choice.
On Tue, Dec 8, 2015, at 04:56 PM, Lukas Stabe via swift-evolution wrote:
> I don’t agree with the premise that forcing `self` everywhere would improve clarity. I love it that lines like this:
> don’t look like this anymore:
> self. buildSubviewInMode(self.mode).forEach(self.addSubview)
> To me, the version without `self` is much clearer. Now of course people may disagree and that’s why a linter might enforce a coding style that requires self. But I don’t think the language itself should enforce that.
> - Lukas
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution