<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Very strong -1.<br></div>
<div>&nbsp;</div>
<div>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></div>
<div>&nbsp;</div>
<div>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:<br></div>
<div>&nbsp;</div>
<div>init(x: Int, y: Int) {<br></div>
<div>&nbsp; &nbsp; self.x = x<br></div>
<div>&nbsp; &nbsp; self.y = y<br></div>
<div>}<br></div>
<div>&nbsp;</div>
<div>-Kevin Ballard<br></div>
<div>&nbsp;</div>
<div>On Fri, Dec 4, 2015, at 02:41 PM, Stephen Celis wrote:<br></div>
<blockquote type="cite"><div dir="ltr">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></div>
<div><div>&nbsp;</div>
<div><div>On Fri, Dec 4, 2015 at 5:34 PM, Rudolf Adamkovič <span dir="ltr">&lt;<a href="mailto:salutis@me.com">salutis@me.com</a>&gt;</span> wrote:<br></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;"><div>To be a little more specific, here’s a real-world example:<br></div>
<div>&nbsp;</div>
<div>
1. Say there’s a method in my class that contains a local variable called “title”.<br></div>
<div>
2. After a while, I decide to remove a part of this method, including the “title” variable.<br></div>
<div>
3. Everything compiles and seems to work just fine.<br></div>
<div>
4. However, I forgot to remove one more line that used the “title” variable.<br></div>
<div>
5. Because we’re in a UIViewController subclass, I'm unknowingly modifying view controller’s title.<br></div>
<div> <span><span class="colour" style="color:rgb(136, 136, 136)"><br>
R+<br></span></span></div>
<div><div><div>&nbsp;</div>
<div>
&gt; On 4 Dec 2015, at 22:51, Rudolf Adamkovic &lt;<a href="mailto:salutis@me.com">salutis@me.com</a>&gt; wrote:<br></div>
<div>
&gt;<br></div>
<div>
&gt; +1<br></div>
<div>
&gt;<br></div>
<div>
&gt; 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></div>
<div>
&gt;<br></div>
<div>
&gt; 2) Also when, say fine-tuning UIKit animations, I find myself wasting enormous amount of time adding and removing "self".<br></div>
<div>
&gt;<br></div>
<div>
&gt; R+<br></div>
<div>
&gt;<br></div>
<div>
&gt; Sent from my iPhone<br></div>
<div>
&gt;<br></div>
<div>
&gt;&gt; On 04 Dec 2015, at 22:19, David Hart &lt;<a href="mailto:david@hartbit.com">david@hartbit.com</a>&gt; wrote:<br></div>
<div>
&gt;&gt;<br></div>
<div>
&gt;&gt; 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></div>
<div>
&gt;&gt;<br></div>
<div>
&gt;&gt; Just as example, my proposition makes the following piece of code illegal:<br></div>
<div>
&gt;&gt;<br></div>
<div>
&gt;&gt; ```<br></div>
<div>
&gt;&gt; struct FooBar {<br></div>
<div>
&gt;&gt;&nbsp; &nbsp;var foo: String = "foobar"<br></div>
<div>
&gt;&gt;<br></div>
<div>
&gt;&gt;&nbsp; &nbsp;func bar() {<br></div>
<div>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;print(foo) // compiler error<br></div>
<div>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;print(self.foo) // compiler happy<br></div>
<div>
&gt;&gt;&nbsp; &nbsp;}<br></div>
<div>
&gt;&gt;<br></div>
<div>
&gt;&gt;&nbsp; &nbsp;func bar2() {<br></div>
<div>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;bar() // compiler error<br></div>
<div>
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;self.bar() // compiler happy<br></div>
<div>
&gt;&gt;&nbsp; &nbsp;}<br></div>
<div>
&gt;&gt; }<br></div>
<div>
&gt;&gt; ```<br></div>
<div>
&gt;&gt; _______________________________________________<br></div>
<div>
&gt;&gt; swift-evolution mailing list<br></div>
<div>
&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div>
&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
<div>
&gt; _______________________________________________<br></div>
<div>
&gt; swift-evolution mailing list<br></div>
<div>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
<div>&nbsp;</div>
<div>
_______________________________________________<br></div>
<div>
swift-evolution mailing list<br></div>
<div> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</div>
</div>
</blockquote></div>
</div>
<div><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"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div>&nbsp;</div>
</body>
</html>