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

Tino Heth 2th at gmx.de
Fri Dec 18 05:35:57 CST 2015

> I think the mandatory self problem is analogous to never wanting to use x!, as! or try!.
For me, there is an analogy that is even more famous and that has lead to endless discussions - tabs vs. spaces:
- There are two contrary standpoints
- Many programmers have a strong opinion
- It is unlikely that both parties will ever agree
- The compiler doesn't care much about the choice

Unlike with the old indentation-problem, I think most promoters of mandatory self have to admit that there are situations where the other side is better, and many of the others would agree that "self." sometimes makes sense.
(the example with the length calculation of a vector imho really benefits from leaving out self, while I think it is good practice to include it when setting a property)
So, instead of alienating a part of the community, or burden the compiler with complex rules when to require self, I say take the "whitespace-solution" and leave the issue for style guides and tools (maybe someone can write a plugin to show or hide the "self." prefix in Xcode ;-)

My solution for mandatory self would be the status quo:
Of course it is nice to have a really detailed specification, but everyone taking a strong standpoint in this discussion should ask himself if he would prefer to decide the issue by a toss of coin or just leave everything as it is (and to make things more fair and higher the wage for the pro-self side, let's assume that it is about either having self where ever possible, or forbid it whenever the circumstances allow it).
I guess there aren't many people who would prefer the risk of the final decision — but please prove me wrong on this.

More information about the swift-evolution mailing list