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

Marc Knaup marc at knaup.koeln
Mon Dec 14 13:32:05 CST 2015

Having so many symbols like @ all over the place kept me from learning and
using Ruby and Perl. It just felt wrong and artificial.
A language quickly becomes more difficult to learn, use and understand when
much of the code consists of symbols.

I love Swift for having such a simple & clear structure and syntax in most
cases. Adding symbols for every instance access on self (which is a very
common case) would oppose these benefits and make its learning curve

On Mon, Dec 14, 2015 at 8:17 PM, Andrey Tarantsov via swift-evolution <
swift-evolution at swift.org> wrote:

> I agree with Ilya here:
> > but they make code editing easier at the expense of readability.
> Disagree. This really depends on the example. E.g. which is more readable:
>     var length: Double { return sqrt(dx*dx + dy*dy) }
>     var length: Double { return sqrt(@dx*@dx + @dy*@dy) }
>     var length: Double { return sqrt(self.dx*self.dx + self.dy*self.dy) }
> I find that this holds true in larger classes as well (or even more). I
> have tons of view controllers and views that do stuff like:
> obj1.prop1 = X
> obj1.prop2 = Y
> ...
> obj1.prop10 = Z
> superview1.addSubview(obj1)
> Adding “self.” everywhere adds a significant amount of visual noise; I've
> tried _property and self.property access styles in Objective-C, and find
> the former one to be noticeably more readable.
> To be fair, there *are* cases when it's not immediately clear if
> something is a property or a variable. That's why you can still add an
> explicit self. if you want. Some of those are also probably code smells.
> A.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151214/5dc4a438/attachment.html>

More information about the swift-evolution mailing list