<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class="">Very strong -1.<br class=""></blockquote><div><br class=""></div><div>I have the impression that this topic can be quite divisive.</div><div> </div><blockquote type="cite" class=""><div class="">
<div class="">The ability to elide `self` in most contexts is really nice. Especially when combined with the fact that SourceKitService lets Xcode syntax-colorize properties/methods nicely so the color of the identifier tells me whether it's a method/property on self or something else. I realize that not everybody will be using Xcode (particularly people on other platforms), but in time we should hopefully see other editors gain support for SourceKit to provide more intelligent handling of Swift code as well.<br class=""></div>
</div></blockquote><div><br class=""></div><div>For me, Swift should be clear even without the help of syntax highlighting. Syntax highlighting should come only as a bonus. On a personal note, I’m colourblind and have great difficulties telling colours apart.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Similarly, I rely on the ability to shadow things (including properties of self) a _lot_. And it's not just me; it's very common for e.g. initializers to use property names as the parameter names, such as:</div>
<div class=""> </div>
<div class="">init(x: Int, y: Int) {<br class=""></div>
<div class=""> self.x = x<br class=""></div>
<div class=""> self.y = y<br class=""></div>
<div class="">}<br class=""></div>
</div></blockquote><div><br class=""></div><div>I agree with you on this, as I often use such idioms. That’s why the shadowing warning is not a good solution IMHO.</div><div><br class=""></div><div>David.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">On Fri, Dec 4, 2015, at 02:41 PM, Stephen Celis wrote:</div>
<blockquote type="cite" class=""><div dir="ltr" class="">Are there warnings/diagnostics that could call out when local variables shadow properties? I generally like that `self` is optional and prefer limiting its use to explicitly call out potential retain cycles. Xcode also makes it easy to introspect variable scope, though Xcode is less of a requirement these days...<br class=""></div>
<div class=""><div class=""> </div>
<div class=""><div class="">On Fri, Dec 4, 2015 at 5:34 PM, Rudolf Adamkovič <span dir="ltr" class=""><<a href="mailto:salutis@me.com" class="">salutis@me.com</a>></span> wrote:<br class=""></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;" class=""><div class="">To be a little more specific, here’s a real-world example:<br class=""></div>
<div class=""> </div>
<div class="">
1. Say there’s a method in my class that contains a local variable called “title”.<br class=""></div>
<div class="">
2. After a while, I decide to remove a part of this method, including the “title” variable.<br class=""></div>
<div class="">
3. Everything compiles and seems to work just fine.<br class=""></div>
<div class="">
4. However, I forgot to remove one more line that used the “title” variable.<br class=""></div>
<div class="">
5. Because we’re in a UIViewController subclass, I'm unknowingly modifying view controller’s title.<br class=""></div>
<div class=""> <span class=""><span class="colour" style="color:rgb(136, 136, 136)"><br class="">
R+<br class=""></span></span></div>
<div class=""><div class=""><div class=""> </div>
<div class="">
> On 4 Dec 2015, at 22:51, Rudolf Adamkovic <<a href="mailto:salutis@me.com" class="">salutis@me.com</a>> wrote:<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
> +1<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
> 1) I actually encountered at least two bugs in my app introduced by this implicit "self" behavior. It can be dangerous and hard to track down.<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
> 2) Also when, say fine-tuning UIKit animations, I find myself wasting enormous amount of time adding and removing "self".<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
> R+<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
> Sent from my iPhone<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
>> On 04 Dec 2015, at 22:19, David Hart <<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>> wrote:<br class=""></div>
<div class="">
>><br class=""></div>
<div class="">
>> I don't understand the reasoning behind removing the need to access instance properties and functions using self. Swift has always seemed to prefer readability to brevity and the feature makes the distinction between local and instance variables/functions crystal clear. Any good reason I shouldn't go on with the proposition?<br class=""></div>
<div class="">
>><br class=""></div>
<div class="">
>> Just as example, my proposition makes the following piece of code illegal:<br class=""></div>
<div class="">
>><br class=""></div>
<div class="">
>> ```<br class=""></div>
<div class="">
>> struct FooBar {<br class=""></div>
<div class="">
>> var foo: String = "foobar"<br class=""></div>
<div class="">
>><br class=""></div>
<div class="">
>> func bar() {<br class=""></div>
<div class="">
>> print(foo) // compiler error<br class=""></div>
<div class="">
>> print(self.foo) // compiler happy<br class=""></div>
<div class="">
>> }<br class=""></div>
<div class="">
>><br class=""></div>
<div class="">
>> func bar2() {<br class=""></div>
<div class="">
>> bar() // compiler error<br class=""></div>
<div class="">
>> self.bar() // compiler happy<br class=""></div>
<div class="">
>> }<br class=""></div>
<div class="">
>> }<br class=""></div>
<div class="">
>> ```<br class=""></div>
<div class="">
>> _______________________________________________<br class=""></div>
<div class="">
>> swift-evolution mailing list<br class=""></div>
<div class="">
>> <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class="">
>> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
<div class="">
> _______________________________________________<br class=""></div>
<div class="">
> swift-evolution mailing list<br class=""></div>
<div class="">
> <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class="">
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
<div class=""> </div>
<div class="">
_______________________________________________<br class=""></div>
<div class="">
swift-evolution mailing list<br class=""></div>
<div class=""> <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</div>
</div>
</blockquote></div>
</div>
<div class=""><img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-bottom:0px !important;margin-right:0px !important;margin-left:0px !important;padding-top:0px !important;padding-bottom:0px !important;padding-right:0px !important;padding-left:0px !important;" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/19452f36cdb8b6d3712671ba453b8d78a9b92ee92269272eba5aaf50cfd9c3b2/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e43505e6373326473336876445348577239737e6d2232433777617a7076736437714a5479753e4d223245445b6a5e6c615f47416d4b674677745b625140513d445e41775e4d4c436965727450523e667b6050763f456675677f46465c45343c647b485033773842597e6239654e4663796746355b67585d223247423b484639403a7d47393a67725b46567740773a7a5342595a7556625133565e657b6e674531593d223641516145566e4273544531666037786d223245595831767872354a5135686444366e6b49334f677d23344d23344/open" class=""><br class=""></div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</blockquote><div class=""> </div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43hXwizS3O2z60WweqomIrdhUedzoU11uXyIiTXgiTnz5CPMNplu3WhoM-2BkDm0KiCd-2BvYchF-2FHAZnTJIdGOB2wmCL-2F1Rz5ieiuDcZs81F4s48BZ2q1MtiFUS0ycnhfebKxAURicS7aRK7Z2vvszI2EF-2B7uoCqe9lVR6J42-2FyNeVa6z3glHPc-2BfaTBRdUQvyaJ-2Bni4EGt3C4i3-2BkfTHNcAGek-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote></div><br class=""></body></html>