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

Kevin Ballard 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.

-Kevin Ballard

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:
>     buildSubviewInMode(mode).forEach(addSubview)
> 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
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list